htaccess删除?category_id = xxxNumbers

时间:2014-03-29 11:22:45

标签: .htaccess filter categories

我到处检查后需要你的帮助。由于Google网站站长工具会将其视为重复的标题和说明。

我需要从复杂的网址中删除一些参数。

FROM:
http://3dstreaming.org/3d-media/videos/7006-avatar-3d-2009-half-sbs-full-hd-1080-dual-hdf-orn.html?category_id=567

TO:
http://3dstreaming.org/3d-media/videos/7006-avatar-3d-2009-half-sbs-full-hd-1080-dual-hdf-orn.html


where "7006-avatar-3d-2009-half-sbs-full-hd-1080-dual-hdf-orn.html"
7006=variable value
avatar-3d-2009-half-sbs-full-hd-1080-dual-hdf-orn=variable words

and remove ?category_id=567  ("?category_id=xxxNumbers")

然后对以下参数相同:

"?start=xxxNumbers"

"?filter_tag=xxxWords"

"?pattern=xxxWords"

有人可以帮助我吗? 提前致谢

我试过这个但是没有工作:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.+?&)category_id=[^&]*(.*)$
RewriteRule ^(index\.php)?$ %{REQUEST_URI}?%1%2 [R=301,L]

1 个答案:

答案 0 :(得分:0)

将以下内容添加到您的htaccess中应该可以实现您的目标

RewriteEngine on
RewriteCond %{THE_REQUEST} \?category_id=   [OR]
RewriteCond %{THE_REQUEST} \?start=  [OR]
RewriteCond %{THE_REQUEST} \?filter=  [OR]  
RewriteCond %{THE_REQUEST} \?pattern=    
RewriteRule ^  %{REQUEST_URI}?%1 [L,R=301] 

添加以下内容将从网址中删除所有参数

RewriteEngine On
RewriteCond %{THE_REQUEST} \ /([^\?\ ]*)\?
RewriteRule ^ /%1? [L,R=301]