httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Slive <jos...@slive.ca>
Subject Re: Mod_rewrite question
Date Tue, 18 Dec 2001 14:11:38 GMT

On Tue, 18 Dec 2001, Alexander Isaev wrote:
> How can I solve the following taks?
>
> I have a site e.g. http://www.my-site.com. It was indexed by Search
> Engines. And  now where a user comes from e.g. http://www.google.com
> I'd like to "rewrite" him to my main page. I use the following
> statement:
>
> ===
> RewriteEngine On
>
> RewriteCond %{HTTP_REFERER} ^http://www\.google\.com/  [NC]
> RewriteRule /* http://www.my-site.com [R,L]
> ===
>

First let me say that this is a very nasty thing to do.  People are using
google to search for a particular thing, and they found it on a particular
portion of your site.  But you are preventing them from accessing that and
shoving them back to your homepage.  This blows the whole purpose of
search engines.  Google is very aggressive in finding and punishing this
kind of manipulation, so if you do this, you may find your site removed
from google entirely.  Even if they don't, I would be loath to visit a
site that did this to me.

Having said that, the proper technique is

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://www\.google\.com/  [NC]
RewriteRule /.+ http://www.my-site.com [R,L]

Your rule said "match any URL with zero or more slashes" (which makes no
sense even if it did not create a loop).  My rule says "match any URL with
a slash followed by at least one more character".  So my URL will not
rewrite if the user hits the site homepage, thus preventing the loop you
observed.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message