【问题标题】:Mod rewrite 301 redirect https with www to https onlyMod重写301将带有www的https重定向到仅https
【发布时间】:2014-10-26 11:36:09
【问题描述】:

我正在尝试重定向,

https://www

到 https,但没有成功。

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^https://www.site.domain$
RewriteRule (.*)$ https://site.domain/ [R=301,L]

这是我尝试过的。

【问题讨论】:

    标签: .htaccess mod-rewrite redirect


    【解决方案1】:

    %{HTTP_HOST} 只匹配没有协议的主机名http://https://

    DocumentRoot/.htaccess 中使用这样的规则:

    RewriteEngine On
    
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.(ivon\.bg)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
    

    【讨论】:

    • 它仍然没有重定向 url
    • 哪个 URL 没有重定向,这个 .htaccess 在哪里?
    • htaccess 工作正常,但从 https:(//www.site).domain 到 https:(//site).domain 的重定向不适用于您给我的示例。
    • 我问的是 这个 .htaccess 在哪里? 我知道它可能对你有用。这个 .htaccess 中是否还有更多规则?
    猜你喜欢
    • 2017-05-03
    • 2018-10-19
    • 2017-06-17
    • 2016-09-24
    • 1970-01-01
    • 2012-06-09
    • 2018-06-01
    • 2018-06-02
    相关资源
    最近更新 更多