Why does local host say "It Works"? [closed]
I have configured all my websites in the "Sites" folder to be tested in my browser. When I type a web address for example http://test.dev, I get "It Works".
Why?
That's the default Apache HTTP index page. It's there to indicate you've correctly installed and enabled httpd.
That page is located in /Library/Webserver/Documents
.
You need to make sure you uncomment the second line of the following:
# User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf
That file then includes the files in /private/etc/apache2/users
There should be one with your username.
You can then go to localhost/~username
, which is equivalent of visiting Users/username/Sites
This probably means that you don't have a specific entry in your web server configuration for for the IP address (if using IP-based virtual hosting) or the name you are trying to reach (test.dev, in your example, if using name-based virtual hosting).
For example, in Apache you can create <VirtualHost>
sections which specify the document root for requests that match the IP and/or name (again, depending on if you're doing IP or name based virtuals). If none of those match, it will fall back to the DocumentRoot and other settings that are set outside of the <VirtualHost>
entries.
So, to resolve it you could either make the virtual host config for the site that you want to receive these requests include this name/IP that isn't currently matching (preferable) or make one of your sites existing in the main config instead of in a <VirtualHost>
(or similar depending on the web server you are using) section.