【问题标题】:Convert http and http://www to https and https://www将 http 和 http://www 转换为 https 和 https://www
【发布时间】:2018-12-30 04:23:28
【问题描述】:

我已将配置文件中的基本 url 更改为 https://mywebsite

但是,如果我输入 www.mywebsite,它不会更改为 https,如果我输入 https://www.mywebsite,它也不会更改

我们不希望这影响相关的 API 和图像。这可能吗?

我们只是想保护我们不同社交媒体渠道的网址。

我们的网站是使用 codeigniter 创建的。

谢谢

【问题讨论】:

    标签: codeigniter url routing


    【解决方案1】:

    您可以在 htaccess 文件中添加这些行

    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [OR]
    RewriteCond %{HTTP_HOST} ^myhost\.com$ [NC]
    RewriteRule ^ https://www.myhost.com%{REQUEST_URI} [R=301,L,NE]
    RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/ 
    RewriteRule ^index\.php(/(.*))?$ myhost.com/$2 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    【讨论】:

    • 谢谢 - 它导致与该网站关联的应用程序无法运行。收到此错误消息:JSON 无法序列化,因为错误:无法读取数据,因为它的格式不正确。
    • 有人能帮忙吗?
    猜你喜欢
    • 2023-03-16
    • 2017-12-04
    • 1970-01-01
    • 1970-01-01
    • 2014-12-16
    • 1970-01-01
    • 2014-05-08
    • 2018-09-26
    • 2015-02-16
    相关资源
    最近更新 更多