Reputation: 21
Domain redirects from http to https in my htaccess file, but none of my urls and folders will redirect from http to https. Example: www.example.com/example.html or www.example.com/folder/example.html will not redirect from http to https
What is the rewrite rule for the htaccess file to redirect all urls and all folders from http to https?
Upvotes: 2
Views: 4009
Reputation: 1757
# add trailing slash to directories and force SSL
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !(/$)
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://www.example.com/$1/ [R=301,L]
# And for the files
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
That's what we have
Upvotes: 5