简体   繁体   English

mod rewrite将所有重定向到https,但一个文件除外

[英]mod rewrite redirect all to https except one file

I would like to redirect all my pages so they use the HTTPS protocol except one path. 我想重定向我的所有页面,以便它们使用HTTPS协议(一条路径除外)。 I did find the following page ( mod_rewrite redirect all to https except one file ), but the solution provided there didn't work for me. 我确实找到了以下页面( mod_rewrite将所有文件重定向到https,除了一个文件除外 ),但是在那里提供的解决方案对我不起作用。 I have also tried other solutions, all to no avail. 我也尝试了其他解决方案,但都无济于事。

Here is my current code: 这是我当前的代码:

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$ $1\.php [QSA,L]

I have edited my post with the exact content and path. 我已经用正确的内容和路径编辑了帖子。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

Try this .htaccess: 试试这个.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$ $1.php [NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM