Page 1 of 1

htaccess puzzle - changing a document base?

Posted: Mon Dec 10, 2007 5:51 am
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.

Posted: Mon Dec 10, 2007 6:03 am
by Benjamin
Why not set it in httpd.conf on them for development purposes and forget it?

Posted: Mon Dec 10, 2007 6:13 am
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.

Posted: Mon Dec 10, 2007 5:18 pm
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.