簡體   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