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

前端 未结 21 972
礼貌的吻别
礼貌的吻别 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:59

    You shouldn't for security reasons. Especially if cookies are in play here. It leaves you wide open to cookie-based replay attacks.

    Either way, you should use Apache control rules to tune it.

    Then you can test for HTTPS being enabled and redirect as-needed where needed.

    You should redirect to the pay page only using a FORM POST (no get), and accesses to the page without a POST should be directed back to the other pages. (This will catch the people just hot-jumping.)

    http://joseph.randomnetworks.com/archives/2004/07/22/redirect-to-ssl-using-apaches-htaccess/

    Is a good place to start, apologies for not providing more. But you really should shove everything through SSL.

    It's over-protective, but at least you have less worries.

提交回复
热议问题