SEO Friendly Rewrite Method to Move Website URL From Subdirectory to Root Parent Folder

You have set up your site, blog such as WordPress, Drupal, LiveJournal, or content management system such as Joomba and Mambo nicely at URL link such as http://www.domain.com/mylovelysite, and get decent traffic to the web site. Now in the reorganization exercise, you decide to move the site from sub-directory to the parent folder, properly at site’s root location instead. Moving the site to another folder or root folder will break all links and backlinks referenced to your website. If these broken links are not handled and redirected properly, there will be a lot of 404 page not found error, potentially drive away visitors, or in worst case, affect and lower the search engine ranking position (SERP).

The best way to manage the change of site’s URL due to movement of directory location is by using redirection feature provided by mod_rewrite module in Apache HTTPD web server. Most web hosts using Apache web server supports mod_rewrite redirect by default, and can implement this trick with ease. Else you will need to enable and turn on mod_rewrite module.

To redirect from a subdirectory or sub-folder to root directory, add the following line of text towards the top of .htaccess file located in the sub-directory to redirect all requests into that folder will be redirected to new location (i.e. root) properly. If the .htaccess file does not exist, create one.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^mylovelysite/(.*)$ /$1 [R=301,NC,L]
</IfModule>

Replace mylovelysite in the forth line above with the directory name on your website’s URL. These line in .htaccess will redirect requests for the /mylovelysite sub-directory to the root directory by stripping “mylovelysite/” out of the URL. For example, a visit to http://www.domain.com/mylovelysite/index.html will get redirected to http://www.domain.com/index.html, instead of returning an 404 error. This is useful for visitors who come to your site via bookmark or favorite, or those find your web pages via search engines that haven’t re-crawled, re-spidered and refreshed with the new URLs in their search indexes in the initial days after moving.

However, the movement will still likely to affect your site’s search engine rankings. The rewrite rules above make sure of 301 permanent redirect to ensure that the PageRank or ranking will pass over to the new URLs for search engine optimization (SEO). Until the new site structures get fully reindexed, the organic traffic from search engines may be reduced temporarily.


8 Responses to “SEO Friendly Rewrite Method to Move Website URL From Subdirectory to Root Parent Folder”

  1. pemilu Indonesia
    February 17th, 2009 17:40
    8

    Very nice information. Thanks for share.Look forward to reading more from you in the future.

  2. SEO Consultant Joel
    October 16th, 2008 04:13
    7

    Wow, this is a great post. Thanks for the information, this is often times an issue that comes up and I can never find a good resource to do this. Make sure you don’t have a ton of links to your sub directory though because some value could be lost.

  3. Erotikshop Liebeslaute
    October 9th, 2008 22:56
    6

    Danke für das schöne Beispiel. Das hat uns wirklich weiter geholfen. Nach einer kleinen Abänderung funktioniert unsere Weiterleitung endlich so wie wir es wollten.

  4. elina
    September 26th, 2008 23:15
    5

    hi

    i have already redirect my primary domain to a subfolder “/folder”. Is it possible to hide the “/folder” name on the url ???

    For example i want primarydomain.com/index.php instead of primarydomain.com/folder/index.php

  5. Can I Easily Change My Blog Directory WITHOUT screwing up links? - DIY Themes Forums
    August 30th, 2008 15:07
    4

    [...] htaccess, but most do). If you don’t have that file in your root directory you can create one. This site should help with specifics. __________________ kristarella.com

  6. Misschief
    August 21st, 2008 08:43
    3

    I’m kind of new to this but couldn’t you just do:

    Redirect permanent /mylovelysite/ http://wwww.domain.com/

  7. Ashish
    June 19th, 2008 19:17
    2

    Thanks dude i tried and it worked fine for my site http://www.hurricanesoftwares.com but unfortunately it didn’t worked out for my other site. Wondering whats wrong.

    Ash

  8. Michael Aulia
    May 8th, 2008 14:40
    1

    Yeah.. I’m thinking to move my blog from /blogs/ to the main root…ugh.. I’m just too scared to do it

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

htaccess rewrite subdirectory - rewriterule subdirectory - mod_rewrite subdirectory - rewrite directory - htaccess rewrite folder - htaccess hide subdirectory - hide subfolder in url - rewrite everythin to subdir - .htaccess rewrite subdirectory - htaccess redirect root to subdirectory - remove folder from url wordpress - link urls to root and subdirectory - mod rewrite subdirectory - rewriterule htaccess subdirectory - htaccess move websiet - mod_rewrite move from subfolder to root folder - apache rewrite root to subdirectory - mod_rewrite remove directory from url - rewrite rule subdirectory - htaccess rewrite redirect folder - move directory .htaccess - htaccess rewrite directory - rewrite rules moving website - htaccess 301 move site - htaccess: rewrite subdirectory - .htaccess rewrite in a directory - .htaccess folder rewrite - hide subdirectory mod_rewrite - htaccess move website - htaccess mod_rewrite under sub folder - htaccess rewriterule subdirectory - mod_rewrite redirect to subdirectory - mod_rewrite redirect to subdir - mod rewrite removing direction in url - mod_rewrite hide subfolder - mod rewrite and hebrew - redirection root website to a sub folder for seo - rewrite Wordpress url seo - RewriteRule subdirectory urls - url rewrite subdirectory main - .htaccess rewrite redirect to subdirectory - .htaccess rewrite folder - htaccess rewrite main to subdirectory - rewriterule move folder - url redirect to subdirectory - website root default rewrite - WordPress Mod Rewrite Make Subdirectory 404 Error - how do i hide subfolders in url with htaccess - htaccess url rewrite moving subdirectories - htaccess move site -