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

时间:2018-05-06 08:58:58

标签: php .htaccess codeigniter amazon-web-services

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/abchttps://www.example.com/abc时重定向。

当我转到example.com/abc显示404错误时,使用上面的代码。

所以请有人帮我解决这个问题。答案很感激。

1 个答案:

答案 0 :(得分:0)

您可以使用:

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