【问题标题】:Redirect article to 301 from directory redirected to 410将文章从重定向到 410 的目录重定向到 301
【发布时间】:2017-02-24 12:38:14
【问题描述】:

我已将目录重定向到.htaccess 中的 410

Redirect 410 /books/videos/

现在我想编写一个规则,将一些文章从 /books/videos/ 重定向到 301 页面。我试了如下

RewriteRule ^(.*)/books/videos/how-to-find-videos.html /books/how-to-find-videos.html [L,R=301]

当我访问 www.mysite.com/books/videos/how-to-find-videos.html 时,它会显示 410 已消失的页面。这意味着这里没有应用 301 规则。我怎样才能为同一目录获得410 and 301

提前致谢。

【问题讨论】:

    标签: php apache .htaccess redirect mod-rewrite


    【解决方案1】:

    不要混合来自不同 Apache 模块的 RedirectRewriteRule 指令。

    按照给定的顺序排列:

    RewriteEngine On
    
    # specific files are redirected with 301
    RewriteRule ^/?books/videos/how-to-find-videos\.html$ /books/how-to-find-videos.html [L,R=301,NC]
    
    # remaining URIs from this path to get 410
    RewriteRule ^/?books/videos/ - [L,R=410]
    

    确保在测试之前清除浏览器缓存。

    【讨论】:

      猜你喜欢
      • 2011-12-08
      • 2011-07-08
      • 2021-04-04
      • 1970-01-01
      • 2015-04-05
      • 2014-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多