Jump to content

Archived

This topic is now archived and is closed to further replies.

faheemhameed

realpath-ing alias folder

Recommended Posts

Hi there,

I have set an alias in the apache conf as follows:

Alias /my_root/ "D:/Apache/hameed/"

My Apache root "/" folder is "D:/Apache/"

Now I have created test.php in the folder "D:/Apache/testing/". The content is as follows:

<?
print realpath("/my_root");

?>

The output is blank instead of "D:/Apache/hameed/"

Please help me and let me know what I am missing here.

Thanks!!
Hameed

Share this post


Link to post
Share on other sites
This is because PHP doesnt send a request through to Apache, to retrive info on a directory/file, include/requiring a file etc or when dealing with files/folders. PHP uses its own request to do this. So if you tell PHP to go to /my_root, it'll goto the root of your hard drive and look for a file//folder called my_root, it wont use the apache alias you setup as it isn't sending a reguest through to apache.

Share this post


Link to post
Share on other sites
Note really. Unless you setup a constent called MY_ROOT, which has the value of D:/Apache/hameed/ like so:
[code]define('MY_ROOT', 'D:/Apache/hameed/');

echo MY_ROOT;[/code]
When creating/using constants they must be in uppercase.
Then when you want to use MY_ROOT you do this:
[code]echo realpath(MY_ROOT);[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.