My site not working when "www" is not used, but it's ok with the "www"

3 posts / 0 new
Last post
#1 Sun, 07/03/2016 - 13:34
tiagobombonatti

My site not working when "www" is not used, but it's ok with the "www"

Hello, everyone! When I type in the "http://www.mydomain.com.br", I can access my site with no problem. The problem is when I don't type the www, the site won't work, leading me to the "APache2 Ubuntu Default Page".

I tried to force redirection via .htaccess, by including this:

RewriteEngine On RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Restarted Apache, with no luck. The problem persists.

I have to tell you all, before that, I was getting a Certificate Error, and then I put this first line in my apache2.conf:

ServerName amantesdocarnavalsp.com.br

The certificate problem was vanished, but I can't access my site without the "www".

Can you help me solve the problem? I believe there's to ways to solve it: by .htaccess redirection or by some configuration on apache2.conf, but no idea what to do. Thank you!

Edit: I'm using Ubuntu 14.04, webmin 1.801, Virtualmin 5.03, Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz, 4 cores

Mon, 07/04/2016 - 08:46
Diabolico
Diabolico's picture

Your Apache config is not configured correctly. You should take a look there especially under virtual server configuration.

- I often come to the conclusion that my brain has too many tabs open. -
Failing at desktop publishing & graphic design since 1994.

Tue, 07/05/2016 - 18:08
tiagobombonatti

The solution was to change "Servername mydomain.tld" to "Servername localhost" in the apache conf. Thank you so much for helping!

Topic locked