阿帕奇mod-rewriteHTTPS只针对特定的URL到http阿帕奇、mod、rewriteHTTPS、URL

2023-09-02 00:59:20 作者:眯眼看世界

我有Apache网络服务器运行,并在我的网站我有HTTPS在会员区。

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

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

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

不过,我不希望用于正常的网站HTTPS。所以,我真的很喜欢它,如果有人会去到https://www.domain.com/example.html被踢回HTTP://www.domain.com/example.html

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

因此​​,只有与它的网址是子页面的https://www.domain.com/members/*应该是HTTPS

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

任何想法,我会怎样配置此?

Any idea how I would configure this?

谢谢!

通过这个code我得到的http://www.domain.com/members要踢httpw://www.domain.com/members

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]

现在我需要的https://www.domain.com/*更改为http:(当然除了/件)//www.domain.com/*

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

推荐答案

使用这种code在你的.htaccess下DOCUMENT_ROOT:

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]

这将迫使所有的 HTTPS:除了那些开头 /件/ 到的http://