How can I force users to access my page over HTTPS instead of HTTP?

前端 未结 21 937
礼貌的吻别
礼貌的吻别 2020-11-28 01:15

I\'ve got just one page that I want to force to be accessed as an HTTPS page (PHP on Apache). How do I do this without making the whole directory require HTTPS? Or, if you s

21条回答
  •  一整个雨季
    2020-11-28 01:44

    You could do it with a directive and mod_rewrite on Apache:

    
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    
    

    You could make the Location smarter over time using regular expressions if you want.

提交回复
热议问题