繁体   English   中英

.htaccess HTTPS重定向,只有一页Laravel

[英].htaccess HTTPS redirect except one page laravel

我想将所有HTTPS请求重定向到HTTP,但包含以下字符串的URL除外:“ / account / buy-premium”

这是我的.htaccess文件:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^/account/buy-premium [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/account/buy-premium [NC]
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller... Default Laravel conf
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

https:// example.com/test-page重定向到http:// example.com/test-page (良好)

https://example.com/account/buy-premium/991重定向到http://example.com/index.php (错误-此处无需重定向)

我找不到任何解决方案来阻止/ buy-premium页面的重定向
请帮忙

由于最后一条规则REQUEST_URI更改为/index.php ,因此您将需要使用THE_REQUEST变量而不是REQUEST_URI

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} \s/account/buy-premium [NC]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !\s/account/buy-premium [NC]
RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller... Default Laravel conf
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

暂无
暂无

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

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