【问题标题】:.htacces redirect from example.com/abc to https://www.example.com/abc.htaccess 从 example.com/abc 重定向到 https://www.example.com/abc
【发布时间】:2018-05-06 08:58:58
【问题描述】:

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 错误。

所以请有人帮我解决这个问题。感谢您的回答。

【问题讨论】:

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


    【解决方案1】:

    你可以使用:

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

    【讨论】:

    • 我想在添加代码之前从现有行中删除任何行吗?
    • 你确定在域上安装了 SSL
    • 是的,我的域上有 ssl
    猜你喜欢
    • 1970-01-01
    • 2019-01-27
    • 2019-12-04
    • 2015-09-25
    • 1970-01-01
    • 2021-09-16
    • 2020-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多