【问题标题】:.htaccess redirect loop - root URL duplicate.htaccess 重定向循环 - 根 URL 重复
【发布时间】:2015-05-26 23:14:43
【问题描述】:

我正在尝试使用 .htaccess 实现以下目标:

  • domain.tld/ 显示原来位于 domain.tld/home/ 的内容
  • 如果您访问 domain.tld/home/,您将被重定向到 domain.tld/(以避免重复内容)

我尝试了以下方法,但它导致了无限循环:

RewriteEngine on
RewriteRule ^$ /home/ [L]
RedirectMatch 301 ^/home/$ /

有什么想法吗?谢谢。

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    找到解决方案:

    RewriteEngine on
    RewriteCond %{THE_REQUEST} \ /+home/([^\?\ ]*)
    RewriteRule ^ /%1 [R=301,L]
    RewriteRule ^$ /home/ [L]
    

    基于:How to avoid duplicate content mapping urls with htaccess

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-26
      • 1970-01-01
      相关资源
      最近更新 更多