简体   繁体   中英

MAMP Virtual host needs www?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM