In File Explorer, go to C:\MAMP\conf\apache
and open httpd.conf
with your text editor.
Find this line:
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
Uncomment this line:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Find this line in that same httpd.conf
file.
<Directory />
Options FollowSymLinks ExecCGI
AllowOverride none
Order deny,allow
Allow from all
</Directory>
Change AllowOverride
from none to all
<Directory />
Options FollowSymLinks ExecCGI
AllowOverride all
Order deny,allow
Allow from all
</Directory>
I have found that MAMP is a bit odd here. Your Virtual Hosts directive goes into C:\MAMP\conf\apache\httpd.conf
. However, the actual httpd-vhosts.conf
file is located at C:\MAMP\bin\apache\conf\extra\httpd-vhosts.conf
, that is, in the bin directory. Not sure why.
In File Explorer, go to C:\MAMP\bin\apache\conf\extra
and open httpd-vhosts.conf
with your text editor.
All the way at the end of the httpd-vhosts.conf
file, you're going to place a code that signifies a virtual host and specifies the path. Place this code at the end of the document.
<VirtualHost *:80>
ServerName example.local
DocumentRoot "C:/MAMP/htdocs/example"
</VirtualHost>
Change the DocumentRoot
to wherever your project is located.
In File Explorer, go to C:\WINDOWS\system32\drivers\etc
and open hosts
with your text editor.
At the bottom of the file, type the name of your virtual host.
127.0.0.1 example.local
Make sure to restart the servers on MAMP after making any changes! If you don't reset the server to apply the changes, nothing will work even though you know you've done everything right.
Can't thank you you enough!! I was struggling with the vhosts not working through the vhosts file vas working directly from the httpd conf. Not sure why MAMP has this oddity or really frustrating issue of keeping the unused vhosts.conf or not pointing to the correct one in its httpd.conf file. Thanks a bunch!!