Jump to content


Photo

realpath-ing alias folder


  • Please log in to reply
4 replies to this topic

#1 faheemhameed

faheemhameed
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 25 July 2006 - 11:15 AM

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



#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 July 2006 - 11:28 AM

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.

#3 faheemhameed

faheemhameed
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 25 July 2006 - 12:28 PM

Hi there,

Thanks for your reply. But how can I work around my issue? It is possible at all?

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 July 2006 - 02:10 PM

Note really. Unless you setup a constent called MY_ROOT, which has the value of D:/Apache/hameed/ like so:
define('MY_ROOT', 'D:/Apache/hameed/');

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


#5 faheemhameed

faheemhameed
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 26 July 2006 - 12:25 AM

Thanks!!

I understand this.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users