: Redirect www to non-www using Apache htaccess does not work I have this in my .htaccess (modified from the default Drupal .htaccess): RewriteCond %{HTTP_HOST} ^www.website.com.com$ [NC] RewriteRule
I have this in my .htaccess (modified from the default Drupal .htaccess):
RewriteCond %{HTTP_HOST} ^www.website.com.com$ [NC]
RewriteRule ^(.*)$ website.com/ [L,R=301]
In theory this will redirect something like www.website.com/asdf to website.com/asdf. However, it doesn't redirect, it allows requests to go through like there was no redirect intended.
(I'm on OS X if it matters, but I've also tried it on a Network Solutions Linux server with the same result.)
More posts by @Cooney921
1 Comments
Sorted by latest first Latest Oldest Best
You need to enable the rewrite engine in your .htaccess file if you have not done already...
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ example.com/ [L,R=301]
Note that I've removed the extra .com on the RewriteCond line that you have in your question - I'm assuming this was a typo?
Also, FollowSymLinks must also be enabled, if not already (should appear before the above)
Options +FollowSymLinks
If it's still not doing anything then it's possible the .htaccess file (or these directives) are not being processed at all. (You can test this by typing some nonsense and see if it breaks!) In which case, look for the AllowOverride directive in your server config / virtual host settings and set this to AllowOverride All (it might be set to None for instance) - or query this with your host.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.