Using Mod Rewrite Rules To Move Folders To A New Domain

Writing by Nick Stamoulis on Thursday, May 7, 2009 Leave a comment

If you have a set of folders that you want to spin off into a separate domain name, that is possible using mod rewrite rules. Let me be clear that the following instructions are for Apache servers. The protocol will be different for Linux and Windows servers. But let’s say you have a blog that you want to spin off into its own domain name.

For instance, your blog currently sits at http://mydomainname.com/blog, but you want to move it to http://myblog.com. How do you move your blog to the new domain name without breaking your links?

Create an .htaccess file out of a blank Notepad document and add this one line of code to it:

RedirectMatch 301 blog/(.*) http://myblog.com/$1

Broken down, the command involves your existing folder at the old domain followed by a forward slash and .* enclosed in parentheses. The asterisk in parentheses tells the user’s browser to include any folder with the preceding antecedent in the command. So any permalink in the blog folder of your domain name will be redirected. Put the .htaccess file in the folder in question (ie blog) and your redirect will be complete.

It’s always best, when you are redirecting a series of pages, to just include the paramaters for the parent page or folder and include all its subservient pages. It’s a lot less work.

Leave a comment                      Category: Webmaster Tools                      

Read similar posts in Webmaster Tools

No Comments

No comments yet.

Leave a comment

XHTML: 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>

Search Engine Optimization Journal is an SEO Blog that discusses Search Engine Marketing, Search Engine Ranking and Positioning for the new and advanced reader.