I have set up a vHost as follows:
<VirtualHost *:80> ServerAdmin [email protected] ServerName example.com ServerAlias www.example.com DirectoryIndex index.php DocumentRoot /var/www/example.com/www/ <Directory /> Options -FollowSymLinks -Includes -Indexes -MultiViews AllowOverride None </Directory> <Directory /var/www/example.com/www/> <LimitExcept GET POST> deny from all </LimitExcept> Options -FollowSymLinks -Includes -Indexes -MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> I would like to add a rewrite rule as follows:
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteCond %{HTTP_HOST} !^dev\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] So that i can add a subdomain to my website, but ensure that all traffic to example.com or anything.example.com besides dev.example.com is directed to www.example.com.
Where would i place this rule to make it effective?
I have tried every which way, including placing it in httpd.conf but it seems to either break the vhost config or have no effect.
Any ideas and suggestions would be greatly appreciated.