[ale] apache redirect based on http referer

Jim Kinney jim.kinney at gmail.com
Tue Jul 29 19:54:54 EDT 2008


I may be thinking this wrong but it seems that the internal phpBB redirect
will bypass the apache rewrite since it takes place outside of the apache
space.  What does RedirectMatch do? It is better at handling regex.

On Tue, Jul 29, 2008 at 6:22 PM, Brian Pitts <brian at polibyte.com> wrote:

> I have a question about how to creating a RewriteCond using the http
> referer with mod_rewrite for Apache 2.2.
>
> In my test environment I have a name based virtual host 'newbb' which is
> hosting an installation of phpBB2. When someone logs in to phpBB via
> POSTing login.php, phpBB responds with a 302 redirect to index.php. The
> web browser then GETs index.php. However, I would like to browser to
> load viewforum.php instead. I could modify phpBB to redirect to
> viewforum.php instead of index.php on login, but I thought I would try
> accomplishing it through this bit of mod_rewrite first:
>
> RewriteCond %(HTTP_REFERER) ^http://newbb/login\.php.*$<http://newbb/login%5C.php.*$>
> RewriteRule ^/index\.php$ viewforum.php?f=2 [R]
>
> The chain of events I expected was
>
> GET login.php
> 200 OK
> POST login.php
> 302 Redirect (from phpBB)
> GET index.php
> 302 Redirect (from mod_rewrite)
> GET viewforum.php
> 200 OK
>
> However, the last three don't happen. mod_rewrite doesn't think the
> request for index.php matches the RewriteCond above. The message in the
> log is
>
> RewriteCond: input='%(HTTP_REFERER)'
> pattern='^http://newbb/login\.php.*$ <http://newbb/login%5C.php.*$>' =>
> not-matched
>
> I have verified using Firebug that the request for index.php does
> includes a referer, e.g.
>
> http://newbb/login.php?sid=c1a3ca063842b5e4a7045c0fc278829d
>
> Any idea what I'm doing wrong? I've read what I thought was the relevant
> apache documentation and googled for examples of rewritecond's using the
> referer but am none the wiser.
>
> For the curious, the backstort is that I'm using mod_rewrite and some
> small changes to phpBB2 to expose one forum through a different domain
> name than the rest of a phpBB installation.
>
> All the best,
> Brian
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>



-- 
-- 
James P. Kinney III
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20080729/ad331257/attachment.html 


More information about the Ale mailing list