Drupal: How to Redirect Moving Site From Subfolder to Server Root
When web site is under construction, it is often stored within subfolder of the existing site so search engines are able to index it. And after the site moves to server root all indexed links become broken. This is not good. In addition, there can be some references to these links…
Solution:
Open .htaccess (the file is located on site root) and add:
RewriteCond %{REQUEST_URI} ^/subfolder
RewriteRule ^subfolder(.*)$ http://site.ru$1 [R=301,L]
Right after
<IfModule mod_rewrite.c>
RewriteEngine on
This is how such redirecting works:
- http://site.ru/folder → http://site.ru
- http://site.ru/folder/ → http://site.ru/
- http://site.ru/folder/* → http://site.ru/*
Advantages:
- There is no waste of links weight (search engines pass weight to a new page)
- Old links still work
Great Post! I am so glad I found this. This is exactly what I was looking for. Thanks for Posting. Ill definately visit again!Regards: SB2011LAIN_AING