将\ tag \重定向到主页

时间:2013-10-05 11:54:54

标签: regex apache .htaccess mod-rewrite tags

我想重定向我的全部

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]

但没有奏效

由于

1 个答案:

答案 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]