views:

395

answers:

2

I need the path specified in $_SERVER['DOCUMENT_ROOT'] to be accessible in .htaccess file. Is there a way to access it there?

I basically need to point to a file kept at the root and need the actual file system path and not the URL path. So instead of using a hard coded value, I'd like to be able to use a variable.

Thanks.

+2  A: 

I believe %{DOCUMENT_ROOT} is only available in RewriteCond

Kevin
+1  A: 

$_SERVER is a PHP variable, whereas .htaccess files use Apache's configuration language. Sadly, there is no way to reach into PHP from Apache's config files.

The solution I've seen in many projects is to have an installation script write a customized .htaccess file out when the application is installed. Not quite ideal and a bit more work, but it gets the job done.

Ryan Ballantyne
I was afraid of that. Guess I will have to create a customized .htaccess file. Thanks Ryan.
Gaurav