Redirect to WWW

Rebuff

Verified User
Joined
Apr 30, 2019
Messages
10
Hello.

How do I make my domain.com to always redirect to www.domain.com? There is setting "Pointers www redirect", but it has no effect (no conf change happens, if I (de)select it).
 
If you're using apache and not nginx, you can use a .htaccess redirect for it:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
That's the one I used.

You might also try to redirect directly to https like this:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
but I have not tested this last one yet.
 
Hello,

"Pointers www redirect" is used for domains which you added as pointers to your main domain only. The solution suggested by Richard should do the things.
 
Forum > Technical Discussion > Nginx (WWW) > Redirect to WWW

I thought there was some integrated way to make that happen.

There is a template /usr/local/directadmin/data/templates/nginx_server_redirect.conf, but don't know how to utilize it.
 
I thought that posting in this section made it clear that I'm using Nginx, not Apache. If not, I am not explicitly saying that I'm using nginx, so there's no htaccess.
 
Yes, but is there any integrated option to easily achieve that in DA, or you have to write custom conf?
 
No, you need to use rewrite rules in custom section, or modify templates per your needs.
 
Back
Top