【问题标题】:Apache Redirect URL with and without WWW带有和不带有 WWW 的 Apache 重定向 URL
【发布时间】:2015-06-24 03:56:17
【问题描述】:

如何重写带有和不带有 www. 的 URL?我的 .htaccess 中的以下代码会将 domain1.com 重写为 domain2.com 而不是 www.domain1.com。

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

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect rewrite


    【解决方案1】:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www\.)?domain1.com$
    RewriteRule ^(.*)$ http://domain2.com/$1 [R=permanent,L]
    

    【讨论】:

      猜你喜欢
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-07
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      • 1970-01-01
      相关资源
      最近更新 更多