Redirecting to PHP script
| From: | Nick Talbott | Date: | Wed, 21 Jun 2000 10:27:28 +0000 |
| Subject: | Redirecting to PHP script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-2461@lists.php.net to get a copy of this message | ||
Hello, new list!
I wonder if anyone has a suggestion to how I might make the following work
(better than the way I am currently doing it). Sorry, this is going to take
a bit of explaining :-)
What I am doing is this: (PHP as Apache module on Linux)
Someone accesses a site using a url like www.mysite.org/john
Now the resource (file or directory) "john" will not exist. What I want to
do is to remap that url to a php script that does a database lookup on
"john" and generates the site from a template.
What I have got working is this:
In the Apache configuration file I have a directive for the (virtual) site
that redirects the 404 error (file not found) to a php script.
ErrorDocument 404 /start.php
This works fine. In the start.php script I check the $REDIRECT_URL and pull
out the requested directory and handle it accordingly.
However, because we are working on the basis of URL errors, my web server
error log will get loaded up with "file not found" errors. It also means
that "genuine" file not found problems are going to get handled wrongly.
What I would like to do:
I have played around with the AliasMatch directive, trying to do something
like ..
AliasMatch ^/(.*) /usr/local/apache/start.php?site=$1
.. but Apache complains this is invalid syntax. It will work if I just say
..
AliasMatch ^/(.*) /usr/local/apache/start.php
.. but then I don't get the variable passed.
Thanks for reading so far! Anyone any ideas on an elegant approach? Is
this one that mod_rewrite could handle?
Nick Talbott
IT Policy and Strategy Manager, Powys County Council, UK
email nickt@powys.gov.uk
FAX +44 (0) 1597 824781
web http://www.powys.gov.uk and http://www.powysweb.co.uk