301 redirect Blogger to another Host and keep Goog

2020-04-20 12:12发布

问题:

first, I apologize for any spelling error. I am french.

I'd like your help for something that may have a simple fix, but I have not found anything specific to my case.

EXPLANATION

I have a site on Blogger platform and a domain registered at Godaddy for about two years. But nowadays, I'm unhappy there because of the many limitations of this platform. I have about 300 posts published and indexed in this blog.

Well, I've just create myself a static website (with many HTML files and some CSS/JS) and bought a Linux Hosting (Deluxe with cPanel) on Godaddy also. I created a subdomain in the parent domain (which is pointed at the Blogger) to test this new static site. Everything's working fine and ready to go...

THE PROBLEM

As I said, I have 300 posts already indexed. I created new HTML files for all these Blogger posts, the way I want, with friendly URL and other customizations. Why? Blogger show my links like this: "mywebsite.com/2010/06/post-name.html." My intention for this new site is to do something like "mywebsite.com/post-name.html". I've set up the paths and everything more in the subdomain.

My question is: How do I redirect the traffic from the old site (Blogger) to the new without losing Google Rank and "bypass" a 404 Not Found error when old links were visited?

I've done several searches on Google and only found tutorials that show how to do this in the migration Blogger to Wordpress.

I know I can't just delete this site on Blogger and (perhaps) something can be done in .htaccess file to solve it. I have to "close" Blogger for now and redirect visitors with a 301 Redirect to the new host to prevent Google punish me for duplicate content, right?

Googling, I found this code:

   <b:if cond='data:blog.url == &quot;http://example.com/2013/01/post-name.html&quot;'>
<meta content='0;url=http://example/post-name.html' http-equiv='refresh'/>
</b:if>

But it was a Blogger-to-Wordpress tutorial.

The code above could be applied in my case? Or should I just create a redirect post by post within the .htaccess?

I appreciate any suggestion and help.

回答1:

If you had your domain pointed at blogger until now, and will have it pointed at your new server in the future, then all future requests will reach your new server automatically. So all you will have to do is set up the rewriting of all “old” URLs to the new targets on your new server.

With a Redirect directive as mentioned by you in comments, you should be able to achieve that. Using this technique, you will need to use a Redirect for each old URL you want to redirect to a new one.

If all of your old URLs follow the pattern of /yyyy/mm/post-name.html, and all of your new URLs are just /post-name.html with the post names being still the same, you might want to use a RewriteRule instead:

RewriteEngine On
RewriteRule ^([0-9]{4})/([0-9]{2})/(.*)$ /$3 [R=301]

This will match on all incoming requests that start with four digits (the leading slash will have been stripped off at that point already), followed by a slash, followed by two digits and another slash, and then just “anything” after that, and will redirect it to that “anything”. It will be prefixed with the protocol and server name automatically. And the [R=301] flag will make this a redirect with 301 status code.

That way, you could catch all of those old post URLs with just one rule, and would not have to write a Redirect statement for each one individually.

(If you need more information about how this works, please consult the mod_rewite documentation first.)



回答2:

If you are trying to redirect one url to another domain on existing page

like http://some-domain.com/2017/abc.html to http://another-domain.com/2017/abc.html

You can use following javascript

<script>
var url = location.href;
var newurl = url.replace('some-domain.com','another-domain.com';);
location.href=newurl;

</script>