mod_rewrite and include paths
| From: | Marcus Bointon | Date: | Sun, 13 Nov 2005 22:05:34 +0000 |
| Subject: | mod_rewrite and include paths | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-225701@lists.php.net to get a copy of this message | ||
This seems like a simple problem...
I have a rewrite like this:
RewriteRule ^x/([0-9]+) x.php?x=$1 [PT,L]
This maps a url like http://www.example.com/x/123 to http://www.example.com/x.php?x=123
x.php contains a line to include some class like:
require_once 'x.class.php';
My include path contains '.' (plus paths to pear, etc), and the class file is in the top level directory.
This configuration will fail with a file not found error. Because of the rewrite, PHP ends up looking for x/x.class.php instead of just x.class.php. If I change the PT option to R (AKA ugly mode), it works fine as PHP gets to know about the real URL.
So how can I get PHP to look in /? I can set include_path with a php_value in .htaccess, but I can only set it absolutely (losing existing values), not add to it (AFAIK?). I don't want to add an absolute path to my global include_path as there may be multiple independent deployments of the same scripts on the server, and I don't want them including each others files. Adding .. to the path would work but is a security risk. Any other ideas?
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus@synchromedia.co.uk | http://www.synchromedia.co.uk