Forum Moderators: phranque

Message Too Old, No Replies

How do I reference files using the realpath in htaccess

Do I use rewritebase?

         

twist

9:31 pm on Apr 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am on shared hosting and my setup is something like this,

Currently my rewriterules look like this,

RewriteRule ^$ /filename.php?var=1 [L]

Which sends them to the filename.php file which looks like this,

<? include( '/usr/path/files/page.php' );?>

Is it possible just to directly access my files in htaccess like this,

RewriteRule ^$ /usr/path/files/page.php?var=1 [L]

The idea would be to keep all php in the root directory. I've tried messing around with RewriteBase but am having no luck.

jdMorgan

2:27 am on Apr 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is that .htaccess cannot rewrite to a filepath that is 'above' it hierarchically. As noted in the documentation, the path to the directory in which .htaccess resides is removed before the RewriteRule pattern is tested, and then added back on to the substitution URL in a per-directory .htaccess context.

On reflection, I hope you will appreciate the security problems that are avoided by doing this.

You can probably do this direct-php-access trick if you put the code in httpd.conf

Jim