我想重定向我的全部
www.website.com/tag/xxxx.html
指向
的链接www.website.com
如何使用.htaccess文件执行此操作?
我试过
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (tag)
RewriteRule ^(.*)$ www.website.com [R=301,L]
但没有奏效
由于
答案 0 :(得分:1)
您可以使用基于mod_rewrite
的规则:
RewriteEngine On
RewriteRule ^tag(/.*)?$ http://www.website.com/ [R=301,L,NC]
PS:只有当您要避免有效文件/目录的此规则时,才需要前2 RewriteCond
行。
或使用mod_alias
:
RedirectMatch 301 ^/tag(/.*)?$ http://www.website.com/
更新:根据您的意见:
RewriteRule ^def/any/(.+)$ /$1 [R=301,L,NC]