: Remove www and force https This has been asked multiple times, but none of the answers have worked for me. I have just installed an SSL certificate and need to force https connections for
This has been asked multiple times, but none of the answers have worked for me.
I have just installed an SSL certificate and need to force https connections for all visitors.
This site has a lot of incoming links, so all existing http links should properly redirect to https.
There should be no There is also a rule that removes .html from files for "friendly" URLs, so that has to continue to work.
This is the old htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ example.com/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ .html [NC,L]
What is the new set of rules I need to use?
More posts by @Hamaas447
1 Comments
Sorted by latest first Latest Oldest Best
I´d suggest:
# ----------------------------------------------------------------------
# | Forcing `https://` |
# ----------------------------------------------------------------------
# Redirect from the `http://` to the `https://` version of the URL.
# wiki.apache.org/httpd/RewriteHTTPToHTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ %{HTTP_HOST}/ [R=301,L]
</IfModule>
# ----------------------------------------------------------------------
# | Suppressing the `www.` at the beginning of URLs |
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
</IfModule>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.