• We value your experience with Plesk during 2025
    Plesk strives to perform even better in 2026. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2025.
    Please take this short survey:

    https://survey.webpros.com/

Automatically add www to naked domain

Y

yoannb

Guest
I would like to a domain automatically redirected to www when entering it in without a prefix in the browser.
How can i do this?

Thank You
 
Hi,

There is no connection with Plesk here, you can obtain this result with a simple .htacces file and appropriated rewrite rules. Google is your friend, you'll find answer quickly ;)
 
not exactly my solution, but thx

The .htaccess file is rewritten automatically by my ecommerce solution.
It works fine, the problem occurs when i go directly to a sub-directory.
I tried putting the htaccess file there but it doesn't work.
that's why I was hoping for a dns related solution...
 
this is something i had a problem with so i came up with a mod_rewrite rule list for htaccess that i just set as my vhost template.

Options +FollowSymLinks

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

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index.htm
RewriteRule ^(.*)index.htm$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/home.htm
RewriteRule ^(.*)home.htm$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/home.html
RewriteRule ^(.*)home.html$ http://%{HTTP_HOST}/$1 [R=301,L]

not only does it force the www domain, it strips out visitors ability to go to /index.html/htm or home.html/htm and instead directs them to /, cleans up analytics and server logs a lot and removes potential duplicate content from the search engines.
 
Back
Top