Frustrated with redirect www.example.tld -> example.tld

Discussion in 'ISPConfig 3 Priority Support' started by Tastiger, Jun 27, 2024.

  1. Tastiger

    Tastiger Member HowtoForge Supporter

    Sorry for sounding clueless but .....
    Not sure if anything to do with redirects has changed in the last few years as I used to have it functioning fine but my spanking new Ubuntu 24.04 Perfect Server with Apache doesn't seem to want to redirect and checking the documentation hasn't shed any more light on the subject.
    I normally wouldn't worry about it but our major contributor gets anal about the site being accessible from www.example.com

    So simply what is the most acceptable method to redirect www to the non www site in ISPConfig3 3.2.12, preferably with a screen shot?
     
  2. pyte

    pyte Well-Known Member HowtoForge Supporter

    I guess something like this should work just fine:
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
    
    If it should not be accessible from the www. subdomain at all, then just remove the www A record in the DNS and disable the auto www subdomain checkbox for the site in ISPConfig
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Nothing has changed, and redirect works fine in Ubuntu 24.04 here in ISPConfig.

    Redirect tab of the website:

    2024-06-27 08_29_33-ISPConfig.png

    The most likely reasons for your issue are:

    1) Additional wrong redirect settings in the site have been chosen beside the one shown above. Either in ISPConfig or in a .htaccess file.
    2) Wrong settings in the CMS of that site. E.g. CMS and shop systems do redirects on their own, independent of the control panel that you use to manage the server.
    3) the server config can not be written to disk e.g. due to a wrong manual config in Apache directives field. Check if there is a .err file for this vhost in the /etc/apache2/sites-available/ folder.
     
    Tastiger and pyte like this.

Share This Page