简体   繁体   中英

redirect from https to http under certain conditions with .htaccess

I'm scratching my head on this one. I need to set up a rule so when someone goes to an address on my site with /members/ in the url it will automatically switch back to http from https.

so kinda like

RewriteCond %{REQUEST_URI} ^/members/
RewriteRule ^(.*)$ http://www.domain-name.co.uk/$1 

well I'm not so great with this type of problem so some help would be very much appreciated.

edit- current .htaccess

 #RewriteCond %{HTTPS} on
    #RewriteCond %{REQUEST_URI} !(acatalog)
    #RewriteRule ^(.*)$ http:// %{SERVER_NAME}%{REQUEST_URI} [R=301]

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} on
RewriteRule ^(members/.*)$ http://%{HTTP_HOST}/$1 [L,R,NC]

This should do the trick:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^members/(.*) http://www.domain-name.co.uk/members/$1 

RewriteCond %{HTTPS} on checks whether https is used. Only if this is true, the RewriteRule will be active.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM