• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

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