如何向mod_rewrite添加一个异常,将Web服务器上的所有流量重定向到https?

如何向mod_rewrite添加一个异常,将Web服务器上的所有流量重定向到https?,https,apache,Https,Apache,我目前正在使用我在网上找到的以下脚本: ######################################### #### BEGIN EDIT FOR MOD_REWRITE #### #### This is intended to force HTTPS #### #### for all inbound HTTP requests #### #### # This module (mod_rewrite) simply tells Ap

我目前正在使用我在网上找到的以下脚本:

######################################### #### BEGIN EDIT FOR MOD_REWRITE #### #### This is intended to force HTTPS #### #### for all inbound HTTP requests #### #### # This module (mod_rewrite) simply tells Apache2 that all connections to # port 80 need to go to port 443 . SSL . No exceptions #### LoadModule rewrite_module modules/mod_rewrite.so RewriteEngine on #### # The line below sets the rewrite condition for mod_rewrite.so. # That is, if the server port does not equal 443, then this condition is true #### RewriteCond %{HTTPS} !=on #ReWriteCond %{SERVER_PORT} !^443$ #### # The line below is the rule, it states that if above condition is true, # and the request can be any url, then redirect everything to https:// plus # the original url that was requested. #### RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] #### END EDIT FOR MOD_REWRITE #### ####################################### ######################################### ####开始编辑以进行MOD_重写#### ####这是为了强制HTTPS#### ####对于所有入站HTTP请求#### #### #这个模块(mod_rewrite)只是告诉Apache2 #端口80需要转到端口443。SSL。没有例外 #### LoadModule rewrite_module modules/mod_rewrite.so 重新启动发动机 #### #下一行设置mod_rewrite.so的重写条件。 #也就是说,如果服务器端口不等于443,则此条件为真 #### 重写cond%{HTTPS}=在…上 #重写cond%{SERVER\u PORT}^443$ #### #下一行是规则,它说明如果上述条件为真, #请求可以是任何url,然后将所有内容重定向到https://plus #请求的原始url。 #### 重写规则^/(*)https://%{HTTP_HOST}/$1[NC,R,L] ####结束MOD_重写的编辑#### ####################################### 该脚本被添加到我的httpd.conf文件中,该文件以LAMP堆栈的形式在CentOS服务器上运行。它正是我所需要的,也就是将服务器上任何站点的所有流量重定向到https

但是,我想为服务器上托管的一个不需要使用https的站点做一个例外。如何配置此异常

我为这可能是一个基本问题而道歉,因为我不是一个专业的开发者

提前谢谢

试试这个

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

我明白了。必须添加以下行作为重写条件:

RewriteCond %{HTTP_HOST} !^www\.example\.com* 重写cond%{HTTP_HOST}^www\.example\.com*
我不明白这是如何为服务器上的单个站点添加异常的…您能解释一下吗?将此添加到您希望重定向到https的站点