mod 重写除一个文件外全部重定向到 https

mod rewrite redirect all to https except one file

我想重定向我的所有页面,以便它们使用 HTTPS 协议,但一条路径除外。我确实找到了以下页面 ( ),但那里提供的解决方案对我不起作用。我也尝试过其他解决方案,但都无济于事。

这是我当前的代码:

Options -Indexes
RewriteEngine On

# do nothing for my-awesome-path.php
RewriteRule ^keg-collars-studio\.php$ - [L]

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}

RewriteRule ^(.*)\.html$ \.php [QSA,L]

我已经用确切的内容和路径编辑了我的 post。非常感谢任何帮助。

试试这个 .htaccess:

Options -Indexes
RewriteEngine On

# Turn SSL off everything but payments
RewriteCond %{THE_REQUEST} !/keg-collars-studio\.php [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=302]

RewriteRule ^(.+?)\.html$ .php [NC,L]