【问题标题】:htaccess Rewrite is Not Changing Browser Address Barhtaccess 重写没有改变浏览器地址栏
【发布时间】:2016-03-25 15:02:46
【问题描述】:

我觉得我在这里遗漏了一些东西。我们最初使用子域 (m.example.com) 来处理移动流量。我们现在希望停止使用它,并且我们希望所有访问 m.example.com 页面的用户都被简单地重定向到 example.com。一切似乎都很好,但是浏览器中的地址栏永远不会改变。如果用户键入 m.example.com,则相同的域仍保留在地址栏中。我错过了什么?这是我的 htaccess 中的重写:

RewriteEngine on
  RewriteRule ^ - [E=protossl]
  RewriteCond %{HTTPS} on
  RewriteRule ^ - [E=protossl:s]

  #custom redirects
  #RewriteCond %{HTTP_HOST} ^example.com
  #RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    你可以使用:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^m\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [R=permanent,L]
    

    【讨论】:

    • 成功了——显然添加的反斜杠是关键。谢谢!
    猜你喜欢
    • 2011-04-10
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多