通过 .htaccess 将 HTTPS 重定向到 HTTP
我使用的是带有默认 .htaccess 的 WordPress,我需要将所有以 https:// 开头的网址重定向到 http://。我的服务器对 http 和 https 协议使用相同的文件夹... 这是我当前的 .htaccess:
# BEGIN WordPress <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] </IfModule>
# END WordPress
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
它适用于 https://www.domain.com/ (重定向到 http://www.domain.com/),但它不适用于 https://www.domain.com/subpages/ (它还会重定向到 http://www.domain.com/)。
请问.htaccess 有什么问题吗?
谢谢
I'm using a WordPress with its default .htaccess and I need to redirect all urls starting with https:// to http://. My server is using the same folder for http and https protocols...
this is my current .htaccess:
# BEGIN WordPress <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] </IfModule>
# END WordPress
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
It works fine for https://www.domain.com/ (redirects to http://www.domain.com/) but it doesn't work with https://www.domain.com/subpages/ (it also redirects to http://www.domain.com/).
Do you see any problem in .htaccess please?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改规则的顺序:
否则 WordPress 规则将捕获 URL 路径不为空的所有请求(即不仅仅是
/
)。Change the order of the rules:
Otherwise the WordPress rule will catch all request that’s URL path is not empty (i.e. not just
/
).