Forum Moderators: phranque

Message Too Old, No Replies

.htaccess questions - alias

         

mihomes

10:04 am on Apr 11, 2011 (gmt 0)

10+ Year Member



Brief background. In my current htaccess I prepend and append a file that is not in the websites root dir. I am looking to enable PHP open_basedir Tweak on the server and of course when doing so this throws an error because it does not have access to these file locations any longer.

My first question is if I were to use an alias something to the likes of

Alias /code/ /home/code/

could I then change this :

php_value auto_prepend_file "/home/code/start.php"
php_value auto_append_file "/home/code/end.php"

to

php_value auto_prepend_file "/home/mysite/code/start.php"
php_value auto_append_file "/home/mysite/code/end.php"

for it to work? If the alias adds that folder to the local sites tree then it would no longer be out of its base, correct?

Second question is I do not use mod_alias, but do have mod_rewrite... is it possible to do something like that in mod_rewrite... map that location and add it to the tree?

phranque

11:21 am on Apr 11, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



auto_prepend_file [php.net] is like an included file that's processed by PHP.
no request is sent to Apache to GET that file.

you can probably simulate the url Alias with a softlink in the file system.

mihomes

6:13 pm on Apr 11, 2011 (gmt 0)

10+ Year Member



I should have been more clear...

php_value auto_prepend_file "/home/code/start.php"
php_value auto_append_file "/home/code/end.php"

is in my .htacess file for the site in question so when the openbase protection is enabled an error with :

Warning: Unknown: open_basedir restriction in effect. File(/home/thefile.php) is not within the allowed path(s): (/home/mysite/:/usr/lib/php:/usr/local/lib/php:/tmp) in Unknown on line 0

So in this manner Apache is requesting the file and preventing it... so I need a way to add it to the tree such as the alias method I believe... yet I use modrewrite

jdMorgan

9:56 pm on Apr 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As phranque pointed out, Apache mod_alias works with HTTP URL requests, and so has no effect whatsoever on included-filepath requests occurring entirely within the server's filesystem... Those do not use HTTP.

Look into links and symlinks -- which allow setting up fake "files" that actually are just pointers to the real file in some other location. That's exactly what you need, and exactly what phranque referred to.

Jim

mihomes

11:12 pm on Apr 14, 2011 (gmt 0)

10+ Year Member



Thanks guys... at the moment I ended up copying the script files to each domain account so they would be included in the actual sites allowed files.

I am in the process of researching suphp and implementing that. From what I can tell I can use open_basedir = to setup an allowed filepath for these files on each account, therefore, I would only need to have the script in one location and could access from each domain account. I have yet to do this though due to some confusion about how the global and local php.ini would work with suphp. Since I would be using the append and prepend values in the php.ini rather than htaccess... it seems as though I would need a php.ini in every folder of every website as people keep telling me it is not recursive as htaccess.

Is this true? Why can't a define a single local php.ini for each website which would be a 'default' for every folder in it... then add a php.ini to those specific folders which would require one for changes?

phranque

8:39 am on Apr 15, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you could also solve the global php.ini file problem by adding a symbolic link to it in every script directory that doesn't contain a local one.