繁体   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