Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAMP Apache virtual directories not working for PHP

Status
Not open for further replies.

Spork52

Programmer
Nov 20, 2007
134
0
0
US
I am using MAMP (version 1.7) to test PHP sites locally. I set up an alias in the Apache http.conf file. It works properly when I am browsing the directories, but includes in my PHP files don't work.

E.g., if I set an alias like this

Code:
Alias /mysite.com/website/aliasfolder/ "/Applications/MAMP/htdocs/realfolder/"
<Directory "/Applications/MAMP/htdocs/realfolder/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
and I have a PHP file in:
Code:
/mysite.com/website/php/
and I try:
Code:
include("../aliasfolder/myfile.php");
where myfile.php is located in
Code:
/Applications/MAMP/htdocs/realfolder/
then the include doesn't work.

But when I browse to /mysite.com/website/aliasfolder/ I end up in /Applications/MAMP/htdocs/realfolder/.

Am I doing something wrong, or is it just not supposed to work this way? Is the alias not set correctly? (I don't anything about Apache.)
 
webservers will only listen on socket 80 (or whatever) for http and https protocols (and other similar web protocols).

include() (assuming you don't specify a protocol) uses the filesystem and not the webserver. By contrast you can _can_ include() via the http protocol

Code:
include '[URL unfurl="true"]http://somesite.com/somepath/to/somepage.php';[/URL]

however you will NOT include the _code_ of somepage.php but the output of that code once had a browser visited that page directly.

to 'get around' this design imperative you can use file system aliases, symbolic links and hard links or you can set the include path in your php.ini or in your code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top