2013-05-27 67 views
0

谷歌已经索引了一些奇怪的网址,现在我得到了一些点击给他们。 我想摆脱这些命中,并将其重写到首页,但似乎我缺乏一些技能来做到这一点。重写奇怪的网址回到网站根

在这个规则我尝试重写www.website.com/?f=到www.website.com, 但它不会做任何事情

RewriteCond %{HTTP_HOST} ^www.website\.com$ 
RewriteRule ^/?f=$ "http://www.website.com/" [R=301,L] 

在这种情况下即时得到www.website。 COM/html的点击率,并试图重写 那些www.website.com根,但不会影响www.website.com/news.html

RewriteCond %{REQUEST_URI} !^/\.html [NC] 
RewriteRule (.*) http://www.website.com [R=301,L] 

--bp

回答

0

您需要理解RewriteRule不匹配查询字符串。让你的规则是这样的:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{QUERY_STRING} ^f= [OR] 
RewriteCond %{REQUEST_URI} ^/\.html$ [NC] 
RewriteRule^http://www.website.com/ [R=302,L] 

一旦你验证它是否工作正常,更换R=302R=301。避免在测试mod_rewrite规则时使用R=301(永久重定向)。