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
.htaccess 强制站点范围的HTTPS,但强制特定目录中的HTTP_.htaccess_Https_Url Rewriting - Fatal编程技术网

.htaccess 强制站点范围的HTTPS,但强制特定目录中的HTTP

.htaccess 强制站点范围的HTTPS,但强制特定目录中的HTTP,.htaccess,https,url-rewriting,.htaccess,Https,Url Rewriting,我已经找过了,但找不到我需要的答案——或者这对我来说很有效。 我有一个通过htaccess强制使用https的网站。 有1个特定目录必须是http(不能是https) 我的htaccess中有以下内容: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} !^/excluded_directory/.*$ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_UR

我已经找过了,但找不到我需要的答案——或者这对我来说很有效。 我有一个通过htaccess强制使用https的网站。 有1个特定目录必须是http(不能是https)

我的htaccess中有以下内容:

RewriteEngine On 
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/excluded_directory/.*$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
这不会强制在“排除的目录”中使用非https。 我还尝试在“excluded_目录”中添加第二个htaccess,但没有效果。
有人能帮我解决这个问题吗?

要将特定目录URL从
https
重定向到
http
,您可以在
/dir/.htaccess
中使用以下命令:

RewriteCond %{HTTPS} on

RewriteRule ^/?thisDir/.*$ http://example.com%{REQUEST_URI} [NC,L,R]

您也可以尝试使用条件语句来获取更多选项。你应该用这个替换你现在的规则

  <If "%{REQUEST_URI} =~ m#^/exclude_directory# && %{HTTPS} == 'on'">
     RewriteEngine On
     RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
  </If>
  <ElseIf "%{REQUEST_URI} !~ m#^/exclude_directory# && %{HTTPS} == 'off'">
     RewriteEngine On
     RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
  </Else>

重新启动发动机
重写规则^(.*)$http://%{http_HOST}%{REQUEST_URI}[L,R=301]
重新启动发动机
重写规则^(.*)$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]