Results 1 to 9 of 9

Thread: Redirect to WWW

  1. #1
    Join Date
    Apr 2019
    Posts
    10

    Redirect to WWW

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

  2. #2
    Join Date
    Jul 2008
    Location
    Maastricht
    Posts
    3,828
    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.
    Greetings, Richard.

  3. #3
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,355
    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.
    Regards, Alex G.

    - Get the best commercial DirectAdmin support and hire me on poralix.com
    - Follow and like @Poralix on Facebook

  4. #4
    Join Date
    Apr 2019
    Posts
    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.

  5. #5
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,355
    Read https://www.directadmin.com/features.php?id=2234 about nginx_server_redirect.conf, it is used only for Domain Pointers.

    You need to use mod_rewrite. See #2
    Regards, Alex G.

    - Get the best commercial DirectAdmin support and hire me on poralix.com
    - Follow and like @Poralix on Facebook

  6. #6
    Join Date
    Apr 2019
    Posts
    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.

  7. #7
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,355
    NGINX has its own rewrite_module: https://nginx.org/en/docs/http/ngx_h...te_module.html
    Regards, Alex G.

    - Get the best commercial DirectAdmin support and hire me on poralix.com
    - Follow and like @Poralix on Facebook

  8. #8
    Join Date
    Apr 2019
    Posts
    10
    Yes, but is there any integrated option to easily achieve that in DA, or you have to write custom conf?

  9. #9
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,355
    No, you need to use rewrite rules in custom section, or modify templates per your needs.
    Regards, Alex G.

    - Get the best commercial DirectAdmin support and hire me on poralix.com
    - Follow and like @Poralix on Facebook

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •