https redirect for Network Solutions

后端 未结 4 514
南笙
南笙 2021-01-03 16:48

I am using Network Solutions as a hosting provider with a UNIX hosting package. I need to redirect certain pages to https (login, etc). After going through a lot of testing,

4条回答
  •  青春惊慌失措
    2021-01-03 17:02

    Use the following to force only certain pages to https. In your section to force http, just include the sections/pages that force https in a negated format.

    Something like this, perhaps: (.htaccess)

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    
    # Force https for mode= login, account or register, and the /admin directory:
    RewriteCond %{HTTPS} !=on
    RewriteCond %{QUERY_STRING} mode=(login|account|register) [OR]
    RewriteCond %{REQUEST_URI} admin/
    RewriteRule (.+) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
    
    # force http for all NON login, account, register (query string)
    # and anything else outside the /admin directory
    RewriteCond %{HTTPS} on
    RewriteCond %{QUERY_STRING} !mode=(login|account|register)
    RewriteCond %{REQUEST_URI} !admin/
    RewriteRule (.+) http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
    

提交回复
热议问题