dimanche 21 octobre 2018

Redirect HTTP, non-www and /index.html to HTTPS://www.website.com

I'd like to redirect the following iterations (and all its subfolders):

http://www.website.com
http://website.com
http://www.website.com/index.html
http://website.com/index.html

TO: https://www.website.com/

I have the following code I've used with a different site, but it redirects from www to non-www, so guess it would need some minor tweaks (open to better solutions as well).

## HTTPS
## index.html to top level
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ https://website.com/%1 [R=301,L]
## www to non-www 
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
## non secure to secure
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]




Aucun commentaire:

Enregistrer un commentaire