【问题标题】:Redirecting domain.com/folder to www.domain.com/folder in Apache?在 Apache 中将 domain.com/folder 重定向到 www.domain.com/folder?
【发布时间】:2013-09-19 03:13:21
【问题描述】:

好的,使用 solution 我可以将 domain.com 重定向到 www.domain.com。但我也想将 domain.com/folder 重定向到 www.domain.com/folder。当我尝试 domain.com/folder 时,我会像 www.domain.comfolder 一样被重定向。如何解决这个问题?

我在 .htaccsess 中的重定向配置

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

【问题讨论】:

    标签: apache .htaccess redirect apache2


    【解决方案1】:

    您可以使用此代码:

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

    确保在其他浏览器中进行测试或清除浏览器缓存。

    【讨论】:

      猜你喜欢
      • 2011-10-10
      • 1970-01-01
      • 2023-01-27
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 2020-04-27
      相关资源
      最近更新 更多