Redirect Subdomain to a Directory

Simple Redirect Subdomain to a Directory

No comment – Post a comment

If you are running Apache for your web server, and mod_rewrite is installed (this is a pretty typicaly module on all installations) this is actually pretty easy.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.yourdomain\.com
RewriteRule ^(.*)$ http://www\.yourdomain\.com/subdomain/$1 [L]

Add this code to your apache configuration file – the easiest location is in the .htaccess file in your root web directory. This should redirect the browser with a 302 Found message.

You can do some pretty fancy things with mod_rewrite, but this is simple and gets the job done!

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.