Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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 使用mod_rewrite和wordpress强制将除/feed之外的所有请求发送到HTTPS_Regex_Apache_Mod Rewrite - Fatal编程技术网

Regex 使用mod_rewrite和wordpress强制将除/feed之外的所有请求发送到HTTPS

Regex 使用mod_rewrite和wordpress强制将除/feed之外的所有请求发送到HTTPS,regex,apache,mod-rewrite,Regex,Apache,Mod Rewrite,Apache VirtualHosts和Mod_Rewrite的新手,但我明白了 我在这里读了好几篇文章,并且全部遵循了它们,尝试了它们,但我仍然没有得到我正在搜索的结果 我的目标是: 强制所有传入请求为HTTPS,但进入/feed的feed除外 这一点是为了feedburner,所以我们可以通过https提供我们的网页,但feedburner仍然能够处理来自wordpress的本地提要 以下是我正在尝试的当前重写规则: RewriteEngine On RewriteCond %{REQU

Apache VirtualHosts和Mod_Rewrite的新手,但我明白了

我在这里读了好几篇文章,并且全部遵循了它们,尝试了它们,但我仍然没有得到我正在搜索的结果

我的目标是:

  • 强制所有传入请求为HTTPS,但进入/feed的feed除外
这一点是为了feedburner,所以我们可以通过https提供我们的网页,但feedburner仍然能够处理来自wordpress的本地提要

以下是我正在尝试的当前重写规则:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/feed
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteLog /xxxx/xxxx/logs/rewrite_log
RewriteLogLevel 3

<Directory />
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</Directory>
重新编写引擎打开
重写cond%{REQUEST_URI}^/喂养
重写规则^(.*)$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
重写日志/xxxx/xxxx/日志/重写日志
重写日志级别3
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
如果我输入www.mydomain.net/feed,url以www.mydomain.net结尾,上述内容将迫使我返回主页。正如我所预料的那样,它迫使所有的东西都使用HTTPS

我可以使用以下重写规则使相反的工作(强制HTTPS打开/feed,HTTP打开任何其他内容):

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/feed
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteLog /xxx/xxx/logs/rewrite_log
RewriteLogLevel 3

<Directory />
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</Directory>
重新编写引擎打开
重写cond%{REQUEST_URI}^/feed
重写规则^(.*)$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
重写日志/xxx/xxx/logs/重写日志
重写日志级别3
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
但是,当我试图像这样反转该语句时,它不起作用,并强制https使用/feed

wordpress在做什么违反了我的规则?不是100%确定目录/块在做什么,但我相信这是wordpress输入的。

试试这个:

RewriteEngine On

#check if https is off, force it on for all except /feed
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/feed [NC]
RewriteCond %{REQUEST_FILENAME} !index\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

#check if https is on, turn off for /feed
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/feed/(.*) [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/feed/%1 [R=301,L]

RewriteLog /xxx/xxx/logs/rewrite_log
RewriteLogLevel 3

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/server-status$ [NC]
RewriteRule ^(.*)$ index.php/$1 [L,QSA]