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

Mar 12, 2012   //   by phpfreelancer.biz   //   Blog, PHP Tutorial  //  No Comments

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


<Location /buy.php>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Location>

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

Leave a comment

Share This Post

RSS Wordpress News