
: Non-www along with https I need to set the following rules: redirect www to non-www (close www) redirect http to https (close http) Suppose I have example.com , How to set the above rules
I need to set the following rules:
redirect www to non-www (close www)
redirect http to https (close http)
Suppose I have example.com , How to set the above rules together in htaccess?
More posts by @Pierce454
2 Comments
Sorted by latest first Latest Oldest Best
Here is the shorter version of your code :
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^ www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]
I solved this problem via :
RewriteCond %{HTTP_HOST} ^(www.example.com)(:80)? [NC]
RewriteRule ^(.*) example.com/ [R=301,L]
RewriteCond %{SERVER_PORT} 80 [NC]
RewriteRule ^(.*)$ example.com/ [R=301,L]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.