Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex .htaccess可将某些区域重定向到https_Regex_.htaccess_Https - Fatal编程技术网

Regex .htaccess可将某些区域重定向到https

Regex .htaccess可将某些区域重定向到https,regex,.htaccess,https,Regex,.htaccess,Https,我试图做的是为文件夹/soap或页面提供服务,这些文件夹/soap或页面的标题是/?p=通过http上传,而站点的其余部分则是通过https上传 RewriteEngine on RewriteBase / RewriteCond %{QUERY_STRING} (^|&)(p=uploads)(&|$) [NC,OR] RewriteCond %{QUERY_STRING} ^$ RewriteRule ^ - [E=IS_HTTP:1] RewriteCond %{SE

我试图做的是为文件夹/soap或页面提供服务,这些文件夹/soap或页面的标题是/?p=通过http上传,而站点的其余部分则是通过https上传

RewriteEngine on
RewriteBase /


RewriteCond %{QUERY_STRING} (^|&)(p=uploads)(&|$) [NC,OR]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ - [E=IS_HTTP:1]

RewriteCond %{SERVER_PORT} 443
RewriteRule ^soap/?(.*) http://www.example.com/soap/$1 [R,L]

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/soap

RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

它似乎适用于soap文件夹,但不适用于带有/?p=uploads的页面

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  !soap/?      [NC]
RewriteCond %{QUERY_STRING} !p=uploads/? [NC] 
RewriteRule ^(.*)$  https://www.example.com/$1    [L,R=301,QSA]

所有URL都被重定向到HTTPS,除了那些具有
/soap
/p=uploads

的URL之外。您应该使用
RewriteCond%{HTTPS}关闭
RewriteCond%{HTTPS}打开
而不是服务器端口。?
/soap
…具有/?p=uploads
的页面??必须同时满足这两个条件,否则其中任何一个条件都可以满足?这仍在强制/?p=通过Http上载请举例说明在跳过规则失败时完整的URL。@Zeb99?您是否删除了问题中的所有规则?他们是不需要的。是的,我现在只是用你的例子-只是改变了example.com。你知道我不确定!地址栏仍然显示-因此我只需修复上载脚本即可通过https工作-尽管/soap文件夹会根据需要恢复为http。谢谢你的帮助