jollins
jollins

Reputation: 48

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]

Upvotes: 1

Views: 110

Answers (2)

anubhava
anubhava

Reputation: 785098

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]

Upvotes: 1

Christopher
Christopher

Reputation: 2057

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.

Upvotes: 0

Related Questions