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).
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
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.
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,893
Location
GMT +7.00
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.
 

Rebuff

Verified User
Joined
Apr 30, 2019
Messages
10
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.
 

Rebuff

Verified User
Joined
Apr 30, 2019
Messages
10
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.
 

Rebuff

Verified User
Joined
Apr 30, 2019
Messages
10
Yes, but is there any integrated option to easily achieve that in DA, or you have to write custom conf?
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,893
Location
GMT +7.00
No, you need to use rewrite rules in custom section, or modify templates per your needs.
 
Top