Thursday, February 3, 2022

[FIXED] Virtual hosts not working on MAMP

Issue

I am running into virtual hosts setup issues on MAMP. Here is my vhosts config

NameVirtualHost *

<VirtualHost *>
        ServerName dev.local.com
	DocumentRoot “/Applications/MAMP/htdocs/local”
</VirtualHost>

<VirtualHost *>
        DocumentRoot /Applications/MAMP/htdocs
        ServerName localhost
</VirtualHost>

Here is my hosts file

127.0.0.1       localhost
127.0.0.1       dev.local.com

now when visiting localhost and dev.local.com both are pointing to index of local directory. I tried various config setting in vhosts file but none is working. I am on MacBook Pro 10.10


Solution

Changed the hosts file like this -

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName dev.local.com
    DocumentRoot /Applications/MAMP/htdocs/local
    ServerAlias dev.local.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /Applications/MAMP/htdocs
    ServerName localhost
</VirtualHost>


Answered By - user6166

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.