簡體   English   中英

.htacces從example.com/abc重定向到https://www.example.com/abc

[英].htacces redirect from example.com/abc to https://www.example.com/abc

htaccess:

RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]  

以上我在.htaccess使用的代碼,現在當有人將example.com/abc鍵入https://www.example.com/abc時,我想重定向。

通過使用上面的代碼,當我轉到example.com/abc它顯示404錯誤。

所以請有人幫我解決這個問題。 答案表示贊賞。

您可以使用:

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM