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

后端 未结 4 1757
天命终不由人
天命终不由人 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:43

    That was a nice post and it seems to redirect to http properly but i want some thing like the following

    RewriteCond %{HTTP_HOST} ^site\.com
    RewriteRule (.*) http://www.site.com/$1 [R=301,L]
    
    #RewriteCond %{SERVER_PORT} !^443$
    #RewriteRule ^products https://www.site.com/products/ [R=301,L]
    
    # Disable SSL on pages other than payments.php
    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_URI} !^products
    RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]
    
    # Require SSL on payments.php
    RewriteCond %{HTTPS} !on
    RewriteCond %{REQUEST_URI} ^products\/?$
    RewriteRule ^(.*)$ https://www.site.com/$1 [R=301,L]
    
    
    RewriteCond $1 !^(index\.php|images|js|css|static|img|payment|robots\.txt|blank.gif)
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    my url is http://www.sitename.com and the trailing forward slash is optional what i need is if there is no text like products in the url then it needs to he http:// and if there is a string products in the uri then it should be https://

    how to do that... when i tried it is going to a loop... redirection loop.

    i am using codeigniter frame work and i have removed index.php from the url.

    so if something like http://sitename.com/products occurred then i want it to be https://sitename.com/products

    and if there no products in the url then it should redirect to http://

提交回复
热议问题