Change the URL to URL with HTTPS

2019-09-14 18:20发布

问题:

I have my .htacces on my server and it looks like so:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

But when I type example.com in my browser it doesn't redirect to https://example.com. How can I do that?

回答1:

It would seem it was just the spelling of .htaccess (filename) that was the problem. This has two s, not one, as stated in the question.

Bit of an aside... the name of this file (per-directory Apache config filename) can be changed in the server config (although this is rare):

AccessFileName .htaccess