Directory Redirect to Subdomain

For the longest time I was redirecting like this

RewriteRule ^(forums.*)$ http://forums.example.com$1 [R=301,L]

without noticing that it’s redirecting to a new subdomain but keeping the directory structure. Essentially redirecting this example to http://forums.example.com/forums/. Which is is bad if you intended to install at the subdomain’s root. It took some reading with the help of Google to realize the proper way is:

RewriteRule ^forums/(.*) http://forums.example.com/$1 [QSA,R=301]

About the Author, Dan Cameron:

I'm the owner and solution engineer at Sprout Venture, a web solutions company that specializes in web development including WordPress.

I started my first blog in 2003 and transitioned to WordPress in 2004. Since moving to WordPress I've written a few plugins and themes for public consumption. Lately I'm busy engineering/building/coding and have only been able to share a few code snippets.

If you're in need of some web development, web design or custom WordPress plugins and/or themes contact me, I'll be happy to discuss it with you.

Read More »

blog comments powered by Disqus