You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Alexander Isaev <A....@astelit.ru> on 2001/12/18 14:02:20 UTC

Re[2]: Mod_rewrite question

Hello Owen,

Tuesday, Tuesday, December 18, 2001, you wrote:

OB> Alexander Isaev wrote:
>> 
>> Hello users,
>> 
>> 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]
>> ===
>> 
>> BUT, when I implement it on my site a weird thing happens. When I
>> click on the link to my site from http://www.google.com the browser
>> stops responding. After checking my www server log files I've
>> noticed the following. The browser requests a page from my site and
>> Apache rewrites it to http://www.my-site.com, but HTTP_REFERER still
>> contains http://www.google.com and Apache rewrites it again to
>> http://www.my-site.com and so on. The only way to stop this process
>>  is to press STOP button in my browser.

OB> Having screwed up a bit on a previous poster's problem, let me have a go
OB> at screwing up your's too :-)

OB> Actually, I think I know this one - you have to rewrite the environment
OB> variable to get out of the loop. You do this using the "E" flag - e.g.

OB> RewriteRule /* http://www.my-site.com [R,L,E=HTTP_REFERER:banana]

I just tried it. And .. It didn't work.

I've found another way to solve this problem (but I don't like it).

RewriteEngine On

RewriteCond %{HTTP_REFERER} ^http://([a-zA-Z0-9-]*)\.google\.([a-zA-Z0-9-]*)/  [NC]
RewriteRule /* http://www.my-site.com/enter/welcome.htm [R,L]

http://www.my-site.com/enter/welcome.htm is frameset document with
http://www.my-site.com in one frame and another frame is zero height.
Also I've disabled RewriteEngine for
http://www.my-site.com/enter/welcome.htm directory. In this case
rewriting works but sometimes it hangs as I described in my previous
letter.

OB> so on the second pass (after having been rewritten once), the
OB> HTTP_REFERER will have been changed to "banana" and so will not trip the
OB> rule. Double-check the syntax in the docs but I think that's the right
OB> track to be exploring.

OB> Rgds,

OB> Owen Boyle.

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




Best regards,
 Alexander                            mailto:A.Isaev@astelit.ru


---------------------------------------------------------------------
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


Re[2]: Mod_rewrite question

Posted by Alexander Isaev <A....@astelit.ru>.
Hello Owen,

Tuesday, Tuesday, December 18, 2001, you wrote:

OB> Alexander Isaev wrote:
>> 
>> 
>> OB> RewriteRule /* http://www.my-site.com [R,L,E=HTTP_REFERER:banana]
>> 
>> I just tried it. And .. It didn't work.

OB> Can't imagine why not. Try switching on rewrite logging and look for the
OB> line:

OB> "setting env variable <xxx> to <yyy>"

Here is the part of the log file.

195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (3) [per-dir /usr/home/wwwuser/www/ppee/] strip per-dir prefix: /usr/home/wwwuser/www/ppee/prev.php -> prev.php
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (3) [per-dir /usr/home/wwwuser/www/ppee/] applying pattern '/*' to uri 'prev.php'
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (4) RewriteCond: input='http://www.google.com/search?q=movies&btnG=Google+Search' pattern='^http://([a-zA-Z0-9-]*)\.google\.([a-zA-Z0-9-]*)/' => matched
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (2) [per-dir /usr/home/wwwuser/www/ppee/] rewrite prev.php -> http://www.my-site.com/
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (5) setting env variable 'HTTP_REFERER' to 'banana'
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (2) [per-dir /usr/home/wwwuser/www/ppee/] explicitly forcing redirect with http://www.my-site.com/
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (1) [per-dir /usr/home/wwwuser/www/ppee/] escaping http://www.my-site.com/ for redirect
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (1) [per-dir /usr/home/wwwuser/www/ppee/] redirect to http://www.my-site.com/ [REDIRECT/302]
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (3) [per-dir /usr/home/wwwuser/www/ppee/] add path-info postfix: /usr/home/wwwuser/www/ppee -> /usr/home/wwwuser/www/ppee/
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (3) [per-dir /usr/home/wwwuser/www/ppee/] strip per-dir prefix: /usr/home/wwwuser/www/ppee/ -> 
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (3) [per-dir /usr/home/wwwuser/www/ppee/] applying pattern '/*' to uri ''
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (4) RewriteCond: input='http://www.google.com/search?q=movies&btnG=Google+Search' pattern='^http://([a-zA-Z0-9-]*)\.google\.([a-zA-Z0-9-]*)/' => matched
195.96.64.172 - - [18/Dec/2001:17:11:01 +0300] [www.my-site.com/sid#82a7fb4][rid#82fe034/initial] (2) [per-dir /usr/home/wwwuser/www/ppee/] rewrite  -> http://www.my-site.com/

OB> Rgds,

OB> owen Boyle.

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




Best regards,
 Alexander                            mailto:A.Isaev@astelit.ru


---------------------------------------------------------------------
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


Re: Mod_rewrite question

Posted by Owen Boyle <ob...@bourse.ch>.
Alexander Isaev wrote:
> 
> 
> OB> RewriteRule /* http://www.my-site.com [R,L,E=HTTP_REFERER:banana]
> 
> I just tried it. And .. It didn't work.

Can't imagine why not. Try switching on rewrite logging and look for the
line:

"setting env variable <xxx> to <yyy>"

Rgds,

owen Boyle.

---------------------------------------------------------------------
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