Home .htcaccess redirect no www to www with SSL
Reply: 0

.htcaccess redirect no www to www with SSL

user1443
1#
user1443 Published in July 20, 2018, 1:09 am

For a long time we have had our site running without www in front, but we have recently been forced to make a change.

We recently changed from domainhere.com to www.domainhere.com. We already had a redirect from http to https, but need to change the redirect from https://domainhere.com to https://www.domainhere.com.

We used this code. How do we make it still redirect to HTTPS but with www in front?

RewriteEngine On
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.skarpeknive.dk/$1 [R,L]

We found this on Stackoverflow, but it doesn't seem to work. The site bugs on domainhere.com then

#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.332788 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO