Forum Moderators: coopster

Message Too Old, No Replies

Aliases in php like in apache

How to use a php-alias to access another path in windows?

         

cangoou

11:05 am on Sep 7, 2007 (gmt 0)

10+ Year Member



Hi.

In Apache, you can do something like:
DocumentRoot d:/www/
Alias /myfolder/ D:/anotherfolder/

Which means that everytime d:/www/myfolder/ is accessed, Apache takes a equivalent file out of D:/anotherfolder/.

I want to do the same with .php-files to do local testing under windows.

Under linux, you would do a symbolic link, but thats not possible in windows xp My includes are always like:
include $_SERVER["DOCUMENT_ROOT"]."/myfolder/test.php"
and I hope I don't have to change them because there a lots ;-)

I tried to extend the include_path in php.ini with "D:/anotherfolder/", but I'm not able to include anything out of this folder with that.

eelixduppy

11:53 pm on Sep 7, 2007 (gmt 0)



>>but I'm not able to include anything out of this folder with that.

You still should be able to but you will have to specify the full path of the file.

cangoou

7:03 am on Sep 8, 2007 (gmt 0)

10+ Year Member



Thanks for your reply.

But if I have to specify the full path: Why do I need a include_path then? Is the include_path only for includes with a relative filename?

coopster

4:15 pm on Sep 10, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You can create symbolic links with Windows XP. Microsoft has a resource tool kit [microsoft.com] that comes in quite handy. Have a look at linkd.

No, you don't need to include the full file path with your PHP includes but your full file path(s) need to be in the include_path php.ini directive.

cangoou

7:08 am on Sep 11, 2007 (gmt 0)

10+ Year Member



Thanks again.

Symbolic links would be a solution, but something like the apache-alias-mechanism would be more easy, because you don't have to create a symbolic link for every folder.

The problem with relative/absolute pathes is, that I need absolute pathes on the server, but for local testing, I would need pathes based on the include_path in php.ini, but only if the path is not existing. Tricky, I know. I thought include_path is used when a path is not found. But that seems not to be the case.

So I guess I have to use the symbolic link solution. So thanks for the link to the resource kit.