: How do I get rid of the "www" with mod_rewrite? I want to get rid of the "www" in front of my domain, and I'm trying the following, but it's not working: RewriteEngine On RewriteCond %{HTTP_POST}
I want to get rid of the "www" in front of my domain, and I'm trying the following, but it's not working:
RewriteEngine On
RewriteCond %{HTTP_POST} ^www.example.com [NC]
RewriteRule ^/(.*) example.com/ [L,R]
Basically, what I hope to accomplish is that someone going to example.com would be redirected to example.com.
Any ideas as to what I'm doing wrong?
I've even tried substituting the second line for this:
RewriteCond %{HTTP_POST} example.com [NC]
More posts by @Holmes151
1 Comments
Sorted by latest first Latest Oldest Best
Assuming your .htaccess is on the right place with the right permissions and
your Apache server is configured to use it and mod_rewrite is enabled:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^/?(.*)$ example.com/ [R=301,L]
Note the HTTP_HOST vs HTTP_POST in your example and that I use a 301 redirect.
This is better since some links may point to the www version and this will let
them count towards your SEO ranking. Search engines will eventually always
send people to the right place.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.