How do I have www + also go to

  • Posted April 19, 2014

Hey guys,

My google-fu hasn’t turned anything up, so I thought I’d ask here.

My current site is But if I go to I get a not found error.

I already have the www A @ record in my DNS for this domain.

I have multiple sites on my droplet, so each one has it’s own config file in: /etc/apache2/sites-available

Below are the contents of my config file (I removed my email address even though it’s on my site): ` <VirtualHost *:80> ServerAdmin ServerName ServerAlias

    DocumentRoot /var/www/adamyala
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    <Directory /var/www/adamyala>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost> `

What else do I have to add for this to work?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This is done using .htaccess usually, it’s called a 301 redirect. <br>You either go with non-www to www or the other way around. <br>So using those terms you can find it on google or other search engines. <br>Sticking with just one is also good for SEO purposes and can increase your Google Page Rank. <br> <br>Here’s generic .htaccess code for www to non-www <br> <br>#Redirect www to non-www <br>RewriteEngine On <br>RewriteBase / <br>RewriteCond %{HTTP_HOST} ^www.(.)$ [NC] <br>RewriteRule ^(.)$ http://%1/$1 [R=301,L]