我已将目录重定向到.htaccess
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
。
提前致谢。
答案 0 :(得分:1)
不要混合来自不同Apache模块的Redirect
和RewriteRule
指令。
按照给定的顺序这样做:
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]
确保在测试之前清除浏览器缓存。