Our client has (sadly) presented a new site URL as www.foo.bar.com instead of foo.bar.com. I need to use .htaccess to remove the www. The site works correctly if www
is not prepended to the URL.
This question comes close but implementing with a subdomain doesn't work.
Here's my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Redirect to non-www domain
RewriteCond %{HTTP_HOST} !foo\.bar\.com$ [NC]
RewriteRule ^(.*)$ http://foo.bar.com/$1 [R=301,L]
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
To clarify, I would like to remove both www
and index.php
from all URLs. So:
http://www.foo.bar.com/yay
-> http://foo.bar.com/yay
FWIW, this is hosted on Rackspace, which requires the Rewrite Base /
directive.