Redirection www

NethServer Version: NethServer release 7.7.1908
Module: PhpMyAdmin SoGo Email

Hi all.

I have a problem on the redirection www.
I have created a virtual host
On my ISP i have setup the DNS www and http to redirect to ip public of nethserver.
If i wrote http://mydomain.com the site appear.
but if i write http://www.mydomain.com i see the " Congratulations, your NethServer installation is up and running!"
Same problem with https://www but not with https://

Thank’s for your help

I have insert this on default-virtualhost.inc on the last line :

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+) [NC] RewriteRule ^.* https://www.%1%{REQUEST_URI} [L,NE,R=301]

www redirect to https://mydomain.com
http redirect to https://
http:// to https://

but https://www.mydomain.com redirect to the Congratulations, your NethServer installation is up and running!

@Goulwen_Jouan

Hi

Try this:

There is no * option under virtual hosts, so you need to define all names you want it to appear under…

My 2 cents
Andy

And unfortunately, there’s no way (other than manually hacking on the templates) to set a “preferred” FQDN–such that the host would answer to both mydomain.com and www.mydomain.com, but if you browse to mydomain.com, it would redirect to www.mydomain.com. I’d like this to be in the panel, but I have no idea how to code it there.

this is two examples of redirections in e-smith templates

expand /etc/httpd/conf.d/default-virtualhost.inc and restart/reload httpd

1 Like

Thank’s for your help.

I have add www on cockpit.
Enabled SSL required.
And after i have add www. on a new request of let’s encrypt certificat.

And all are OK.

Thank’s all !

2 Likes