Apache mod rewrite https to http only for a specif

2019-08-09 03:11发布

问题:

I have Apache webserver running and on my website I have https for the member area.

https ://www.domain.com/members/*

But I don't want https used for the normal website. So I would really like it if someone would go to https ://www.domain.com/example.html to be kicked back to http ://www.domain.com/example.html

So only the URL with it's subpage https ://www.domain.com/members/* should be https.

Any idea how I would configure this?

Thanks!

With this code I do get http: //www.domain.com/members to be kick to httpw: //www.domain.com/members

RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} members 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}  [R,L]

Now I need that https: //www.domain.com/* is changed to http: //www.domain.com/* (of course except the /members)

回答1:

Use this code in your .htaccess under DOCUMENT_ROOT:

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

RewriteCond %{HTTPS}s on
RewriteRule ^(?!members/).*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R,NC]

This will force all the https:// URIs except those starting with /members/ to http://