You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Stephen Brooks <sb...@stephenbrooks.org> on 2002/09/29 22:55:16 UTC

[users@httpd] RedirectMatch regex question

I've been trying to redirect URLs requested as
http://stephenbrooks.org/ral/dirs/dirORfile to a PHP script as a query in
the form http://stephenbrooks.org/ral/index.php?dirs/dirORfile .  I have
tried various things with the RedirectMatch command and my best attempt so
far has been:

RedirectMatch ^/ral/?([^?]*)$ http://stephenbrooks.org/ral/index.php?$1

...but this redirects to the site's 404 page.  I'm filtering out requests to
the /ral/ path that are already PHP queries (avoiding an infinite loop!) by
the [^?]* device insisting no ? character appears in the expression.
 - Removing the other ? in the expression that makes the slash optional does
not help.
 - In case you were wondering, the ErrorDocument 404 directive appears
_below_ this one in the .htaccess file in the root directory of the site (no
.htaccess file is present in the /ral directory itself).

It would be great if anyone out there could help.


---------------------------------------------------------------------
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
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RedirectMatch regex question

Posted by Robert Andersson <ro...@profundis.nu>.
Stephen Brooks write:
> I've been trying to redirect URLs requested as
> http://stephenbrooks.org/ral/dirs/dirORfile to a PHP script as a query in
> the form http://stephenbrooks.org/ral/index.php?dirs/dirORfile .  I have
> tried various things with the RedirectMatch command and my best attempt so
> far has been:
>
> RedirectMatch ^/ral/?([^?]*)$ http://stephenbrooks.org/ral/index.php?$1

Don't know exactly what the problem might be, but I think this should work
RedirectMatch /ral/(.*)$  http://stephenbrooks.org/ral/index.php?$1

This, of course, causes an infinite loop, but does what you want otherwise.
I tried hard with similar approach like you ([^?*), but it made no
difference, for reasons unknown to me.
I thought, I would be able to help you out here, but I failed ;) So, I guess
it's up for you to wait for a wizard to answer or take the easy way and put
that index.php in another directory to avoid the infinit loop.
Btw, as long as the /ral/ directory exist, you don't have to make the slash
optional, as apache will take care of the redirection for that first.

Regards,
Robert Andersson


---------------------------------------------------------------------
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
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org