• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

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