Force redirect to SSL for all pages apart from one

后端 未结 1 1877
挽巷
挽巷 2020-12-18 16:27

I\'m trying to use apache2\'s mod_rewrite to force SSL connections to a website. So far, it\'s working fine with the following in the site\'s

相关标签:
1条回答
  • 2020-12-18 17:00
    RewriteEngine On
    
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^thing/add/\d+/page3$ - [L]
    
    RewriteCond %{SERVER_PORT} ^443$
    RewriteRule ^(thing/add/\d+/page3) $ http://%{HTTP_HOST}/$1 [QSA,NC,R,L]
    
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [QSA,NC,R,L]
    

    The rules are processed top to bottom; the first one stops rewrite for maps page if not on SSL; the second one (optional) redirects these pages to non-secure if accessed via SSL; for all else, the old rule applies.

    0 讨论(0)
提交回复
热议问题