Unable to get www to redirect to non-www website

  • Posted December 2, 2013

I’m trying to redirect the site “” to site “”, but I’m not getting it performs. The site opens, but no redirect is done.

Here are my dns zone file and my .htacess file

$TTL 1800 @ IN SOA NS1.DIGITALOCEAN.COM. ( 1386026866 ; last update: 2013-12-02 23:27:46 UTC 3600 ; refresh 900 ; retry 1209600 ; expire 1800 ; ttl ) IN NS NS1.DIGITALOCEAN.COM. NS NS2.DIGITALOCEAN.COM. NS NS3.DIGITALOCEAN.COM. @ IN A imagens CNAME email CNAME drive CNAME calendario CNAME www CNAME

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^$ [NC] RewriteRule ^(.*)$$1 [R=301,L]


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.

I got it. It was an BOM on the .htacess file. Removed the BOM and it worked like a charm. <br>Thank you guys!

I’m not using a virtualhost. It’s in the main apache folder /var/www

In your Apache config file, what do you have listed for the <code>ServerName</code> and <code>ServerAlias</code> directives?