【问题标题】:Rewrite condition on Drupla7 without prefix 'www'在没有前缀“www”的 Drupla7 上重写条件
【发布时间】:2014-12-02 17:44:14
【问题描述】:

我只是想将所有用户重定向到使用“www.”访问该网站。前缀(http://example.com/... 将被重定向到http://www.example.com/..。)

我在 drupal 7 .htaccess 中添加了默认代码。

它在 Mozilla 和 Chrome 而不是 IE 中完美运行。

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

请建议这个在 IE 中工作

【问题讨论】:

    标签: .htaccess mod-rewrite drupal-7 wamp


    【解决方案1】:

    尝试将您的 .htaccess 行更改为

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    

    【讨论】:

      【解决方案2】:

      您也可以在您的 apache 设置中执行此操作。我不会在 .htaccess 文件中这样做。

      在你的

      /etc/apache2/sites-available/SITENAME

      做一些类似的事情:

      <VirtualHost *:80>
       ServerName http://www.example.com
       Redirect / http://example.com
      </VirtualHost>
      

      【讨论】:

        猜你喜欢
        • 2010-12-10
        • 2011-01-13
        • 2013-08-01
        • 2015-10-26
        • 2015-12-30
        • 2017-07-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多