I've recently set up a domain name through godaddy.com. I edited my A record to point to my servers IP address. I then set up a sites-available file and symlinked that to the site-enabled directory. When I go to the url "mydomain.com" I get the index.html file in /var/www/index.html which just says "No Direct Access." When I go to the url "www.mydomain.com" I get my app properly. My sites-available file for the domain is fairly basic, looks like:

<VirtualHost *:80>
    ServerName www.mydomain.com
    DocumentRoot /path/to/my/app
    <Directory />
    <Directory /path/to/my/app/>
        Option FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

When I try this sites-available file WITHOUT the www in the server name, I can not get to the app either way. When I add the "www" to the server name (as it is above) I get the app, but can not then go to just "mydomain.com" or I get the "No Direct Access" error. Anyone know how I can use either "www.mydomain.com" or just "mydomain.com" to access the site?


Add a ServerAlias.

ServerName www.mydomain.com
ServerAlias mydomain.com


ServerName mydomain.com
ServerAlias www.mydomain.com

Make sure both your root domain and www point to the web server in your DNS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.