[SOLVED] ISPConfig 3, Debian 8, Nginx: How to redirect www to no-www (or remove)

Discussion in 'Installation/Configuration' started by Rafael Santana, May 31, 2017.

  1. Rafael Santana

    Rafael Santana New Member

    Hi Guys!
    I'm having a basic difficulty, and I'm wasting a lot of time figuring out how to solve it.

    I created a site and enabled the Lets Encrypt SSL certificate.
    The domain is already working already with the certificate.
    However, I have the address of 2 urls
    Https : // www. mysite. com
    Https :// mysite .com

    How do I remove the www url and leave only the no-www?

    Settings Prints
    imgur. com / g3ibdce and imgur. com / xtoDRiD
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Open the website settings, go to the redirect tab and choose www.domain.tld => domain.tld in the seo redirect field, then press save.
     
  3. Rafael Santana

    Rafael Santana New Member

    Thanks for the answer!
    Change made.
    Redirect Type: No redirect
    SEO Redirect: www.domain.tld => domain.tld
    Rewrite Rules: none

    Problem persists. I still have 2 urls. How strange, is not it?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    1) Are you sure that you connect to the corrcet server?
    2) If you really connect to that server, then it might be that the config could not be written. Is there a vhost.err file for this website in the sites-enabled folder of the web server config (apache or nginx)?
     
  5. Rafael Santana

    Rafael Santana New Member

    How can I verify this? Do I need to check any information in this file that you mentioned?
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Take a look into the folder /etc/apache2/sites-available/. Is there a file with the file ending .err for this domain?
     
  7. Rafael Santana

    Rafael Santana New Member

    I'm using Nginx.
     
  8. ahrasis

    ahrasis Active Member

    Just change apache2 to nginx.
     
  9. Rafael Santana

    Rafael Santana New Member

    Sorry.... But I did not understand. As well? I'm using Nginx instead of Apache. And do you guide me to trade Apache for Nginx? Is Apache still running on the machine?
     
  10. Rafael Santana

    Rafael Santana New Member

    Last login: Tue May 30 22:23:59 2017 from MYIP

    root@server:~# ls /etc/apache2/sites-available/
    000-default.conf default-ssl.conf

    root@server:~# ls /etc/nginx/sites-available/
    apps.vhost mysite.com.br.vhost
    site3.com.br.vhost mysite.com.br.vhost.err
    certbot roundcube.vhost
    default vps.vhost
    default.bak vps.vhost.save
    ispconfig.vhost site2.com.br.vhost
     
  11. ahrasis

    ahrasis Active Member

    Sigh... I mean just change apache2 in /etc/apache2/sites-available/ to nginx i.e. /etc/nginx/sites-available/.
     
  12. Rafael Santana

    Rafael Santana New Member

    Okay. Thanks for the reply.
    How to make this change? In which file?
     
  13. Rafael Santana

    Rafael Santana New Member

    I noticed that the settings of the files
    mysite.com.br.vhost and mysite.com.br.vhost.err are different.
    I found it very curious.


    File: mysite.com.br.net.br.vhost

    server {
    listen *:80;

    listen *:443 ssl;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate /var/www/clients/client1/web2/ssl/mysite.com.br-le.crt;
    ssl_certificate_key /var/www/clients/client1/web2/ssl/mysite.com.br-le.key;

    server_name mysite.com.br www.mysite.com.br;

    root /var/www/mysite.com.br/web/;

    if ($scheme != "https") {
    rewrite ^ https://$http_host$request_uri? permanent;
    }


    index index.html index.htm index.php index.cgi index.pl index.xhtml;



    File: mysite.com.br.vhost.err

    server {
    listen *:80;

    listen *:443 ssl;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate /var/www/clients/client1/web2/ssl/mysite.com.br-le.crt;
    ssl_certificate_key /var/www/clients/client1/web2/ssl/mysite.com.br-le.key;

    server_name mysite.com.br ;

    root /var/www/mysite.com.br/web/;

    if ($http_host = "www.mysite.com.br") {
    rewrite ^ $scheme://mysite.com.br$request_uri? permanent;
    }
    if ($scheme != "https") {
    rewrite ^ https://$http_host$request_uri? permanent;
    }


    The configures that are right and in the vhost.err file, correct? In vhost are not they?
     
  14. ahrasis

    ahrasis Active Member

    You already did that in the earlier post.
     
  15. Rafael Santana

    Rafael Santana New Member

    ahrasis, till : Thanks for the help and patience. I deleted the domain and the vhost file. I did it again, I waited for a while and it worked.
     

Share This Page