.htaccess redirect based on requested domain

April 28th, 2008
No Gravatar

Imagine you have a selection of domain names that point to the same site, are some of those domains specific to certain areas of your site?

Here’s how I redirect a domain name to a specific area on a site

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?cubecartexperts\.co.uk
Rewriterule ^(.*)$ http://www.i9000networks.com/landing-page/cubecart-experts/ [L]

You’ll also need the domain set in your virtualhost config like this

ServerName www.i9000networks.com
ServerAlias www.cubecartexperts.co.uk
ServerAlias cubecartexperts.co.uk

It is a much more helpful way of helping your users navigate your site.

Bookmark it del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Propeller | Yahoo


Was this post useful to you? Let me know, buy me a beer!
Alternatively, if you're feeling impecunious, you may like to subscribe to my RSS feed, or see other articles in the Apache, Domains, Geekery, Linux category.

Leave a Reply