Forum Moderators: phranque

Message Too Old, No Replies

double rewrite rule not working

         

forzatio

8:15 am on Jan 17, 2007 (gmt 0)

10+ Year Member



RewriteEngine on

RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com [NC]
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_USER_AGENT} googlebot [NC]
RewriteRule \.html$ [newwebsite.com...] [R=301]

RewriteCond %{HTTP_USER_AGENT} msnbot [NC]
RewriteCond %{HTTP_USER_AGENT} Slurp [NC]
RewriteRule \.html$ [anotherwebsite.com...] [R=301,L]

note: with this htaccess I want to refer googlebot to a different url than msnbot and Slurp , so I used another rewriterule for that, but it's not working. it doesn't refer any referers or useragents.

jonrichd

11:05 am on Jan 17, 2007 (gmt 0)

10+ Year Member



If I read your code right, you are in effect saying that if the referrer is not example.com and the referrer is not blank, and the UA is Googlebot, then redirect to newwebsite.com.

So, the only case when this rule would be triggered would be if the UA was Googlebot, and there was a referrer string that wasn't example.com. Since legitimate Googlebot doesn't have a referrer string, I don't think you're going to get the redirect.

The second part of your code says if the UA is msnbot and the UA is slurp, then do the redirect. This isn't going to happen either. Perhaps you meant:

RewriteCond %{HTTP_USER_AGENT} msnbot [NC OR]
RewriteCond %{HTTP_USER_AGENT} Slurp [NC]

forzatio

2:20 pm on Jan 17, 2007 (gmt 0)

10+ Year Member



alright, I thought that the useragent googlebot condition was apart from the referer conditions above it, so that was my mistake there.
I removed those first two lines now.

the condition for msnbot was indeed [NC,OR]