help with duplicate content issue

Discuss practical ways rearrange URLs using mod_rewrite.

help with duplicate content issue

Postby TheWebHead » Thu Aug 07, 2008 1:47 pm

In wordpress I'm getting spiders coming up with URLs like this:
http://domain.com/page/4/?s=search+term

when it should only work with this url
http://domain.com/?s=search+term

So I'd like to do something like this:
RewriteRule ^page/([0-9]+)/?s=(.*)?$ http://domain.com/?s=$1 [R=301,L]

but it doesn't work... help
TheWebHead
 
Posts: 12
Joined: Wed Aug 08, 2007 8:43 am

Postby richardk » Fri Aug 08, 2008 7:44 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)(s=[^&]+)(&.*)?$ [NC]
RewriteRule ^.+$ /?%2 [R=301,L]

Do you have Wordpress mod_rewrite already? This should go first, and you do not need to repeat the Options or RewriteEngine lines.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby TheWebHead » Sat Aug 09, 2008 6:10 pm

I came to realize after I posted this that it's probably a better idea just to exclude this in robots.txt. I have 60,000 posts and about 4,000 pages, so if this error worked itself out to a conclusion, googlebot would hammer my site even w/ 301s. Since there's nobody else linking to me like that, I don't have to worry about page rank issues, so robots.txt seems to be a better solution.
TheWebHead
 
Posts: 12
Joined: Wed Aug 08, 2007 8:43 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 13 guests

cron