【发布时间】:2019-10-01 17:09:42
【问题描述】:
我想使用 .htaccess 文件将页面从 HTTPS 重定向到 HTTP。
我已经为一个页面添加了代码,但是当我为 page2 添加它时,它会给站点一个重定向错误。
这是我的代码,适用于 .htaccess 中从 HTTPS 到 HTTP 的一页,我还确保 .htaccess 位于该目录中,其中包含我想要重定向的文件。
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/page1.php$ [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L]
RewriteCond %{SERVER_PORT} !80
RewriteCond %{REQUEST_URI} ^/page1.php$ [NC]
RewriteRule ^(.*)$ http://mywebsite.com/$1 [R,L]
但是当我像下面这样添加它时它不起作用并且我收到重定向错误。
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/page1.php$ [NC]
RewriteCond %{REQUEST_URI} !^/page2.php$ [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L]
RewriteCond %{SERVER_PORT} !80
RewriteCond %{REQUEST_URI} ^/page1.php$ [NC]
RewriteCond %{REQUEST_URI} ^/page2.php$ [NC]
RewriteRule ^(.*)$ http://mywebsite.com/$1 [R,L]
我希望页面仅使用 .htaccess 文件转到 HTTP 而不会出错:
http://mywebsite.com/page1.phphttp://mywebsite.com/page2.php
【问题讨论】: