【发布时间】:2023-03-17 00:41:02
【问题描述】:
所以我一直碰壁尝试了许多不同的选项和配置。我正在尝试将我的网站重定向到 https,但我希望将其从 https 重定向到 http 然后保持 http 的特定 URI 除外。我将不胜感激任何帮助。这是通过虚拟主机配置完成的。以下是我与 ssl.conf 和 mysite.conf 配对尝试过的设置。但是,我不断收到重定向循环或无法加载的页面。
mysite.conf
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !/example
RewriteRule ^(.*)$ https://my.site.com$1 [R,L]
或
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^(/|page1|page2)
RewriteRule ^(.*)$ https://my.site.com$1 [R,L]
或
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !=/example
RewriteRule ^(.*)$ https://my.site.com$1 [R,L]
或
RewriteCond %{REQUEST_URI} =/example
RewriteRule ^(.*)$ http://my.site.com$1 [R,L]
加上上述之一。
然后在 ssl.conf 中
RewriteEngine on
RewriteCond %{REQUEST_URI} =/example
RewriteRule ^(.*)$ http://my.site.com$1 [R,L]
【问题讨论】:
标签: apache mod-rewrite redirect httpd.conf