0
votes

I update my /etc/hosts file as

127.0.0.1 www.mysite.com

Then in the MAMP's httpd-vhosts.conf, i updated the ServerName as

ServerName     www.mysite.com
DocumentRoot   /Applications/MAMP/htdocs/mysite

Now, it's working fine. So when I input mysite.com in the browser, it shows the index.html that is inside my folder /Applications/MAMP/htdocs/mysite.

My question is, when I first check the internet on how to create virtual host in MAMP, the examples never use www. in the MAMP .conf file above. So what I did, I remove the www. in the /etc/hosts file and remove also from ServerName in MAMP's .conf file. Now it doesn't work. So do we really need to add the www. in these files?

Another question is since I want to put the index.html inside /Applications/MAMP/htdocs/mysite/public_html, so what I did is I set the DocumentRoot to /Applications/MAMP/htdocs/mysite/public_html instead. Is this correct? It seems to work. Sorry for the confusion I'm kinda new to this thing.

1
Did you restart the server after updating the vhosts? - Elias Van Ootegem
Yes, I always restart the server whenever I update the files in MAMP - iPhoneJavaDev
The www. prefix does not have any special meaning but many people love typing it every time. You could as well start all your URLs with littleyellowbird. if you wish. - Álvaro González
the problem is it doesn't work if i put just mysite.com in both hosts file and vhosts.conf. when i write mysite.com in safari browser, i got blank page. safari automatically prefix with www. - iPhoneJavaDev
i set mysite.com in /etc/hosts... then i set www.mysite.com as ServerName then i set mysite.com as ServerAlias in vhosts.conf... it didn't work - iPhoneJavaDev

1 Answers

0
votes

There is no need do configure the conf file directly. Just use the MAMP interface. "littleyellowbird.com" as domain and in the alias section put "www.littleyellowbird.com". Mamp rebuilds a conf each time you save the settings, your changes have a good chance to get overwritten. If you want to get to "littleyellowbird.com" even when you enter "www.littleyellowbird.com" in the browser, use a rewrite rule in the .htaccess file for this domain. Greetings, Peter