htaccess puzzle - changing a document base?

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

htaccess puzzle - changing a document base?

Post by onion2k »

I need to run a site on several different severs all of which are configured differently (my dev server, another persons dev server, a demo laptop, and a live site). The code is fine, but the htaccess file that handles redirection isn't.

On my server it'll contain things like:

Code: Select all

ErrorDocument 404 /devserve1/sitetitle/version1/error.php?error=404
But on the demo laptop that needs to be:

Code: Select all

ErrorDocument 404 /laptop/demos/sitetitle/version1/error.php?error=404
Is there a way to make these the same, and add a single directive to tell Apache how to handle them properly? Something like..

Code: Select all

SetEnv SITE_PATH "/laptop/demos"
ErrorDocument 404 %{SITE_PATH}/sitetitle/version1/error.php?error=404
That didn't work unfortunately.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Why not set it in httpd.conf on them for development purposes and forget it?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

astions wrote:Why not set it in httpd.conf on them for development purposes and forget it?
Because the other persons dev server configuration is something that can't change. If I could do this by changing httpd.conf on all the servers the problem wouldn't have arisen, but I can't, hence this thread. :(

I am making a little progress..

The mod_rewrite stuff can be done via:

Code: Select all

RewriteRule .* - [E=site_path:/laptop/demos]

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^survey\/([0-9]+)\/(.*)$ %{ENV:site_path}/survey.php?s_id=$1 [NC,L]
That doesn't work for ErrorDocument directives though so it's not really ideal.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I wonder if there is just a way to make the path relative so full paths would not be required. I believe I have done that before in a similar circumstance.
Post Reply