Jump to content

realpath-ing alias folder


faheemhameed

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

Link to comment
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.
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.