.htaccess 301 redirect problem for non-www in Plesk

Must Read : .htaccess 301 redirect problem for non-www in Plesk

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:

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.webdevdoor.com when I should have entered webdevdoor.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.

(Visited 54 times, 1 visits today)

Leave a Comment.