Remove session ID only for bots

New to mod_rewrite? This is a good place to start.

Remove session ID only for bots

Postby alhermette » Fri Jul 17, 2009 2:22 pm

I need to remove session IDs (SID=xxxxx) from query strings for certain bots if it is present. Any other variables in the query string (should any exist) should be left unaltered. The position of SID within the query string is unknown.

Can somebody confirm if this is correct please.

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} ^(slurp|googlebot) [NC]
RewriteCond %{QUERY_STRING} ^(.*&)?SID=([^&]+)(&.*)?$ [NC]
RewriteRule .* %{REQUEST_URI}?%1%3 [R=301,L]
alhermette
 
Posts: 18
Joined: Mon Mar 16, 2009 2:44 pm

Postby richardk » Sat Jul 18, 2009 8:38 am

It looks fine to me. You should check if search engines will penalise you for different behaviour for them only.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 26 guests

cron