Apache Server configuration support - How to set referer in redirect?

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > August 2004 > How to set referer in redirect?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to set referer in redirect?
Patrick Finnegan

2004-08-22, 6:25 pm

Running " Apache/1.3.20 (Win32)".

The HTTP_REFERER variable is usually set when the user clicks on a
link to go from one page to another. I have a scenario where a user
requests the home page and is immediately redirected by Apache to a
login page. The application behind the login page requires the
HTTP_REFERER but I can see from the access logs that this is null.

For example the user requests;

GET /homepage.html

The response is a 302 redirect to GET /login.html

The http_referer in the new request is null.

I have tried setting the http_referer variable in the redirect and
while the redirect works it does not seem to send the referer back to
the calling browser as in the subsequent request the referer header is
null.

E.G

RewriteCond %{REQUEST_URI} ^/homepage.html$
RewriteRule ^/homepage.html$ https://www.mysite.com/login.html
[R=301,E=%{HTTP_REFERER}:http://www.mysite.com/homepage.html,L]

Is this the way to force the remote browser to set the referer header?

Regards.
faxe

2004-08-22, 6:25 pm

Patrick Finnegan napisał(a):
> Running " Apache/1.3.20 (Win32)".


HTTP 1.1 specification states it clearly: if a 3XX code is given, no
Referer value is passed. (eventualy, the URL that pointed to 3XX site).

--
Paweł Zdziarski
Jabber: fax3@chrome.pl
fax3@jabberpl.org
Patrick Finnegan

2004-08-22, 8:49 pm

faxe <patrz-tekst@w.sygnatur.ce> wrote in message news:<cg4j85$knj$1@atlantis.news.tpi.pl>...
> Patrick Finnegan napisał(a):
>
> HTTP 1.1 specification states it clearly: if a 3XX code is given, no
> Referer value is passed. (eventualy, the URL that pointed to 3XX site).


Changed rewrite rule so no referer.

RewriteCond %{REQUEST_URI} ^/homepage.html$
RewriteRule ^/homepage.html$ https://www.mysite.com/login.html
[E=%{HTTP_REFERER}:http://www.mysite.com/homepage.html,L]

Rewrite log indicates that Apache does implicit redirect.

Changed the substitution to URI /homepage.html rather than complete URL.

RewriteCond %{REQUEST_URI} ^/homepage.html$
RewriteRule ^/homepage.html$ https://www.mysite.com/login.html
[E=%{HTTP_REFERER}:http://www.mysite.com/homepage.html,L]

No longer get implicit redirect but referer is still not set.
HansH

2004-08-23, 2:53 am

"Patrick Finnegan" <chppxf1@yahoo.com.au> schreef in bericht
news:a1538a71.0408221737.360f55ad@posting.google.com...
> Changed the substitution to URI /homepage.html rather than complete URL.
>
> RewriteCond %{REQUEST_URI} ^/homepage.html$
> RewriteRule ^/homepage.html$ https://www.mysite.com/login.html
> [E=%{HTTP_REFERER}:http://www.mysite.com/homepage.html,L]
>
> No longer get implicit redirect but referer is still not set.

Server-Variables, like %{REQUEST_URI}and %{HTTP_REFERER}, are _not_ the same
as enviroment variables. http://httpd.apache.org/docs/mod/mod_rewrite.html

[PT,L] _might_ do a better trick for you.

Note, checking referer is bad habit: now-a-days browsers can be set _not_ to
sent one ever!!

HansH


Patrick Finnegan

2004-08-23, 8:03 am

chppxf1@yahoo.com.au (Patrick Finnegan) wrote in message news:<a1538a71.0408221737.360f55ad@posting.google.com>...
> faxe <patrz-tekst@w.sygnatur.ce> wrote in message news:<cg4j85$knj$1@atlantis.news.tpi.pl>...
>
> Changed rewrite rule so no referer.
>
> RewriteCond %{REQUEST_URI} ^/homepage.html$
> RewriteRule ^/homepage.html$ https://www.mysite.com/login.html
> [E=%{HTTP_REFERER}:http://www.mysite.com/homepage.html,L]
>
> Rewrite log indicates that Apache does implicit redirect.
>
> Changed the substitution to URI /homepage.html rather than complete URL.
>
> RewriteCond %{REQUEST_URI} ^/homepage.html$
> RewriteRule ^/homepage.html$ https://www.mysite.com/login.html
> [E=%{HTTP_REFERER}:http://www.mysite.com/homepage.html,L]
>
> No longer get implicit redirect but referer is still not set.


Gave up trying to set referer. Used HTTP_COOKIE as filter instead as
this will be null on initial request to site.

RewriteCond %{REQUEST_URI} ^/homepage.html$
RewriteCond %{HTTP_COOKIE} =""
RewriteRule ^/homepage.html$ https://www.mysite.com/login.html [L]
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com