Search code examples
apachemampvirtualhosthttpd.conf

MAMP virtual hosts not working when connected to home network


I have virtual hosts setup on my laptop, which I know work fine as I use them often for work and school, but for whatever reason when I'm at my parents house connected to their home network I get 404'd. If I disconnect form the network I get servered the page fine by Apache. Here is my httpd.conf file contents (only the portion dealing with virtual hosts):

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

<VirtualHost *>
    DocumentRoot "/Users/kyle/Sites/ESA/app/public"
    ServerName esa.loc
    <Directory "/Users/kyle/Sites/ESA/app/public">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from all
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

<VirtualHost *>
    DocumentRoot "/Users/kyle/Sites/portfolio-site/public"
    ServerName kyle.loc
    <Directory "/Users/kyle/Sites/portfolio-site/public">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from all
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

and my /etc/hosts file:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost esa.loc kyle.loc
255.255.255.255 broadcasthost
::1             localhost esa.loc kyle.loc
fe80::1%lo0     localhost esa.loc kyle.loc

If you need anymore information let me know and I'll do my best to provide it. Thanks.

EDIT: Forgot to mention that I tried adding my laptop to the DMZ on the router but that didn't fix the issue.


Solution

  • I'm really not sure, but shouldn't Virtualhost contain some information about port? Sth like:

    <VirtualHost *:80>
    

    I think you can remove these lines because it is useless in your case

    NameVirtualHost *
    
    Allow from 127.0.0.1 
    

    It does not make any sense to use ip address in "Allow" when you use "allow from all" on the line above