2017-02-24 70 views
1

我已经重定向目录410 .htaccess重定向文章从目录301重定向到410

​​

现在我想写一个规则的一些文章从/书籍/视频/重定向到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

在此先感谢。

回答

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] 

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

+1

感谢@anubhahva它为我工作。 – Hemantwagh07