.htaccess 301 redirect problem for non-www in Plesk

26 May, 2013 by Tom Elliott

A frustrating problem when trying to get .htaccess redirecting from a non-www domain to the www left me scratching my head for ages. I knew the .htaccess file was fine – had triple checked the code and uploaded the file to the website httpdocs root, but for some strange reason any redirect rules set for the non-www version of the domain did not work at all.

The code for the .htaccess non-www 301 redirect is as follows:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^tomelliott.com
RewriteRule (.*) https://tomelliott.com/$1 [R=301,L]
</IfModule>

Eventually I found the root of the problem. On Plesk (Plesk 11), I had somehow managed to create incorrect DNS settings. When I had setup the domain in the Plesk control panel, I inserted the full domain including the www i.e. www.tomelliott.com when I should have entered tomelliott.com. This caused ‘www’ to appear unnecessarily in all the DNS settings.

As the non-www was not defined properly in the DNS, it did not correctly interpret the non-www redirect rules set in the .htaccess file and showed me the Plesk holding page instead.

To fix the problem, under websites & domains, select the domain and under the ‘general’ tab, make sure your domain is set as non-www – i.e. example.com instead of www.example.com. Check the DNS settings again (under websites & domains) and all but the last entry should now have the ‘www’ omitted.

DNS Settings Plesk



Activating Plesk 11 Backup Manager and Scheduling Backups »
Setting the www or non-www in Plesk 11 »
Updating Plesk 10 to Plesk 11 on Windows »


Leave a Reply

Your email address will not be published. Required fields are marked *

css.php