.htaccess 301 redirect for all https to http EXCEPT ONE PAGE

后端 未结 4 1761
天命终不由人
天命终不由人 2020-12-01 13:12

Here is the code I have currently in my .htaccess file:

Options +FollowSymLinks 
RewriteEngine on
RewriteBase / 
RewriteCond %{HTTP_HOST} ^example.com [NC] 
         


        
4条回答
  •  不思量自难忘°
    2020-12-01 13:33

    # Rewrite Rules for example.com
    RewriteEngine On
    RewriteBase /
    
    # Redirect from example.com to www.example.com
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    
    # Disable SSL on pages other than payments.php
    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_URI} !^payments\.php$
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    
    # Require SSL on payments.php
    RewriteCond %{HTTPS} !on
    RewriteCond %{REQUEST_URI} ^payments\.php$
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
    

    I haven't tested it but something like that should work

    Edit: Updated

提交回复
热议问题