How to do 301 .htaccess for a new sites website

We have an old website that we are replacing with a new Google Sites website. We will use the same domain name (URL) so we need a way to do a 301 .htaccess kind of redirection.

What is the best way to do this?

0 11 2,983
11 REPLIES 11

Hi!

Just to be clear, you need just to change de CNAME to a new URL. So that way the people will cotinue to access the same url, right?

The Google sites have this feature in admin console.

Fist you have to create and publish you google sites. 

After that, go to Admin console > Apps > Workspace > Google sites > Custom URL

1ยบ - Chose the site type

Screenshot_168.png

2ยบ The published Google Sites URL:

Screenshot_171.png

3ยบ Here is where you gonna add the custom URL you want:

Screenshot_172.png

4ยบ You have to do this configuration on you domain DNS zone:

Screenshot_174.png

Just click in add custom URL and it's done.

Hello,

Thank you for the reply, but that is not the problem.

We have an existing website hosted with another provider. We rewrote the site in Google Workspace using new Sites.

Now we need to migrate from the old provider to the new website in Google.

We have to use the same url, and we need to redirect old links to the new website. We can't name the pages the same because the old site has extensions, for example the old page name homepage.html vs the new Sites name of homepage with no extension.

Normally, you would have .htaccess with 301 to redirect, but we can't do that.

How do we transition the old site to the new site without breaking links?

Google has a old site to new site migration tool.

Try to convert the website using this resorce:

Screenshot_177.png

This will disconect the new site  from the old.

The old one can be converted posteriorly.

With this copy you can see if there's no problem with the links and if it's all good, you can do the conversion on the original.

We already converted the old site from html to new Google Sites. Now we need to redirect from the old site to the new site.

Normally you can do .htaccess with 301 records that provide auto redirect  to the new pages without 404 broken links when users try to access the old pages.

Because it is the same URL, once we go live with the new site, the old site cannot exist as it was. We won't have the old pages to forward from.

That's why we need .htaccess 301 functionality.

You don't need a 301 Redirect for this situation, because you're using the same site URLs.

The old site has an "A" record in DNS, no doubt, but the new website in Google Sites will refer to the Sites service via a CNAME record instead (ghs.googlehosted.com.), and mapping specified via the Admin Console.

When you're ready to do the switchover, remove the "A" record and add the CNAME and Google Sites mapping.  The same website URL will now point to the Google Sites website.

Thank you for the reply.

The problem is that any old links to the original pages with .html extension will have no way to be redirected to the new Google sites pages.

For example, https://www.example.com/page.html which has external links to it, now that we have converted the page to new Google sites, once we point to the new site with the original url, it will be https://www.example.com/page without the html extension. Since we have no way to point users to the new page, they will get a 404 and our SEO will be messed up.

We thought about naming the new page like this: page.html, but sites removes the dot, so it becomes pagehtml and would get a 404.

We submitted an idea for Sites to convert requests for page.html to page_html or pagehtml so we can at least code pages that way on Google Sites to prevent the 404 and give users the links to the new pages. It would be even better if there was a way to code the pagehtml type pages to auto-redirect to the new pages.

@AFMSAdmin2 Google Sites doesn't offer any kind of redirects so your links will break, sorry.  You will need to make a feature request to get this added but you chances of getting are slim as it's been asked for since the launch of new Sites and in classic Sites too.

Thank you for your reply.

We were hopeful there was something we were missing, but it appears there really is no proper way to migrate to new Google Sites.

Now we are pondering a way to use .htaccess on the old server to sort of migrate in place.

First, use rewriterule and rewritecond to remove the .html extension from certain pages

Then, use 301 from the old page to the new page, still on the old server. The new page without the .html extension would be the same url as the new page on Google Sites.

Example:

https://example.com/mypage.html use .htaccess to change to https://example.com/mypage

Then use .htaccess 301 to redirect mypage.html to mypage (still on the old server)

Let this "in-place" migration sink in for a while until users have had enough time to change their links.

The new Google site (not published to the final url yet) would have this page also coded as mypage to match the extensionless page on the old server

When we change the DNS from the old server to Google, the new pages will have the same url's that people linked to during the in-place migration and just magically work.

Got the idea from migrating from a website written in Wix to a new Google site. The Wix pages did not have extensions, so we just named the pages the same in Sites. When we changed the DNS to Google, we were up and running immediately, all links still valid, no redirection necessary.

This technique seems solid in theory, though it costs us more time to migrate to the new website than we originally planned.

Are you using Google Domains for your DNS?

Google Domains does offer a 301/302 redirect as an option on Domain Forwarding.  It's essentially a combination of DNS Domain Forward and mapping similar to the Sites mapping in the Admin Console.

 

Thank you for the information.

We are not using Google Domains for our DNS, but will consider using it if this feature would help us migrate the website from the old server to the new Google Sites website using the same url.

This does not appear to be a solution for our problem. It looks like it forwards at the domain or subdomain only, but we need forwarding for individual pages that have external links. Can you give an example of how to forward individual pages like the following? https://example.com/index.html to https://example.com/home

Top Labels in this Space