1

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.

matheo jean
  • 101
  • 6
  • A meta refresh is a bad idea in terms of keeping search engine rankings (because it is not a “real” redirect). As for .htaccess – can you even use that on blogger? – CBroe Jun 20 '15 at 19:46
  • Thanks for reply CBroe. No, Blogger doesn't support htaccess. But once the domain will remain the same, I believe that I could create the redirects in the .htaccess that Godaddy hosting provides after I point the IP to the new site. Am I wrong? – matheo jean Jun 20 '15 at 19:53
  • Ah, yes, of course you can do that. (Based on your phrasing of the question, I thought you wanted to change domains or something, and then redirect incoming request on the old domain to the new one – and in that case, it would need to happen “on” the old domain.) But what’s your specific question then – how rewriting with .htaccess works in general? There’s tutorials for that. If you want to know anything more specific – then you’ll need to be more specific in your question. – CBroe Jun 20 '15 at 19:57
  • Sorry, CBroe. I have a domain registered at Godaddy and I'm using it on Blogger. However, I created a new site (static) and wish to leave Blogger and work with my own server (provided by Godaddy also). However, the main domain wont be modified. What I'd like to know is how I can close the Blogger and redirect all visitors to the new URL (friendly in this case) without losing my ranking on Google. How could I close the Blogger and redirect all URLs (which are already indexed) for the new? What would be the best solution for this? Sorry if I still can not clarify my doubt. But I'm a bit lost :( – matheo jean Jun 20 '15 at 20:15
  • If you had your domain pointed at blogger until now, and will have it pointed at your new server in the future, then all 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. – CBroe Jun 20 '15 at 20:17
  • Thanks CBroe. Ok. I create the 301 redirects from old to new links within the .htaccess, right? But what about Blogger blog? I can leave it active normally without running the risk of punishment for duplicate content? Or should I also put a redirect in Blogger HTML too? – matheo jean Jun 20 '15 at 20:21
  • Why not simply close that blogger account for good, after you moved to your new server? – CBroe Jun 20 '15 at 20:23
  • Wow, I could even do this? I ask because when I read migration tutorials for Wordpress, for example, they emphasize that we can't erase the old Blogger to not affect the ranking in Google. In fact, it's just this question that is making me worried because my site already has a good Page Rank. – matheo jean Jun 20 '15 at 20:30
  • Again, you have your own domain, lets say `example.com`, that _right now_ points to your blog on blogger – and in the future, it will point to your own server, correct? So search engines, as well as all other clients, will still use the same domain to request the content from in the future – only that content will not come from blogger any more, but from your own server. So they won’t even _know_ that your content _was_ on blogger before – so why keep that content? – CBroe Jun 20 '15 at 20:34
  • Man, I'm an idiot :( Now I understood perfectly, CBroe. Sorry about the nuisance that I have caused you. Thank you very much. Just to finish, the 301 redirect should be done within the .htaccess only, right? In this case, the code would be this, for example? **redirect 301 /2015/06/oldurl.html hxxp://www.example.com/newurl.html** – matheo jean Jun 20 '15 at 20:41
  • No worries :-) Yes, since all requests will still be going to the same domain, you only need to set up the rewriting stuff on your new server. The example `redirect` line you have shown should work, however keep in mind that this treats the `URL-path` argument as a _prefix_ only, so if you had old URLs such as `/2015/06/oldurl.html` and `/2015/06/oldurl.html/foo/bar`, it would redirect both to the new URL (unlikely case however). – CBroe Jun 20 '15 at 20:46
  • And in case you have a _lot_ of old URLs to redirect, that would need a _lot_ of `redirect` statements as well. In that case, using a `RewriteRule` could be preferable (if the old and new URLs follow a _pattern_ that can be expressed via regular expressions), or to use a script for it that has a look-up table of some sorts. But for a start, with `Redirect` you should be able to achieve what you want. – CBroe Jun 20 '15 at 20:48
  • Perfect CBroe, my friend. Thanks for your time. I'd like to give +1 to you, but in comments that may not right? Cheers – matheo jean Jun 20 '15 at 20:51
  • Added an answer for you. Plus, since all of your old blogger URLs seem to follow a very specific format, I added how this could be done using a `RewriteRule` that matches this pattern as well. This way, you would not need to create a separate redirect for each individual URL. – CBroe Jun 20 '15 at 21:07

2 Answers2

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.)

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • Thank you so much CBroe. I couldn't add +1 in your answer 'cause I don't have 15 reputations (according to the error that appears). Sorry :( As for RewriteRule, in the case, the old URls follow the same format (which is standard Blogger). However, the new website URLs won't follow the same format. My site is about music in general. Blogger URLs are /yyyy/mm/musicname.html. The new site will look like: /artist/musicname.html or /news/postname.html So I can't use the RewriteRule, right? If I have many Redirect lines in my .htaccess can I have some problem? Thanks more one time lol – matheo jean Jun 20 '15 at 21:32
  • 1
    No, in that case you won’t be able to do this using a `RewriteRule`, since it can’t know _which_ “artist” to use in the new URL (since the old URL doesn’t contain that information) – so you will have to set this up statically, using individual `Redirect` directives. How many old URLs are we talking about here? For a few dozen this is totally ok – if it goes into the hundreds or more, then it might be better to rewrite all of those old URLs to a server-side script, that can look up the new URL in some kind of data structure, and then issue the redirect from within that script. – CBroe Jun 20 '15 at 21:38
  • Well, I have 307 old URLs to redirect :(... Then, basing me in your response, it would be appropriate a server-side script, right? Can you give me a reference (a link perhaps) of how this script works please? – matheo jean Jun 20 '15 at 21:47
  • What kind of server-side scripting language do you have available? Does your server support PHP? – CBroe Jun 20 '15 at 21:52
  • Yes, my server support PHP. But the whole site will work with HTML. The only thing, for now, I think of adding in PHP is a contact form. No problem? – matheo jean Jun 20 '15 at 22:03
  • 1
    Here’s an example of how to do with this a PHP script: https://www.saotn.org/redirect-old-url-new-url-send-404-page-php/ It uses an array to define the mappings of old relative URLs to the new ones. If it finds the requested URL in the array, it redirects to the new one with a 301 status code, otherwise it outputs status code 404 and the HTML code of the 404 page in the lower part of the script. – CBroe Jun 20 '15 at 22:13
  • 1
    You can either use `ErrorDocument 404 /path-to-script.php` to set this up, then it will handle all requests for which your server can not find a document to serve, or a `RewriteRule ^([0-9]{4})/([0-9]{2})/.* /path-to-script.php` – then it will only handle requests for URLs that follow that specific pattern. – CBroe Jun 20 '15 at 22:13
  • Perfect. I'll try CBroe. It seems really better to use a server-side script like that. Man, you helped me a lot. Sorry to have taken your time with these questions. Thank you very much and hugs! =) – matheo jean Jun 20 '15 at 22:24
0

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>
Akshay Mishra
  • 1,535
  • 2
  • 15
  • 14