【发布时间】:2018-01-06 10:57:21
【问题描述】:
我需要一个 mod_rewrite 将所有 http 请求重定向到 https,但我想排除一个 URL
这是我目前在 .htaccess 文件中的内容。
# force https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/template/.*$ [NC]
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,QSA]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
http://example.com/template/` 不应被重定向。但它正在被重定向到主页。
http://example.com/template/
301 Moved Permanently
https://example.com/index.php
301 Moved Permanently
https://example.com/
200 OK
谁能弄清楚为什么它会导致重定向到主页?
谢谢!
【问题讨论】:
-
你是清除浏览器缓存还是使用隐身模式?
-
是的,也通过redirect-checker.org/index.php查看
标签: wordpress apache .htaccess mod-rewrite