Redirect nethserver site to vhost

Hi Nethserver Community

I would like to redirect the nethserver site /var/www/html to one of my vhosts

nethserver is setup as mail.mydomain.co.nz

I would like the webpage at mail.mydomain.co.nz to be redirected to my vhost which is a WordPress site at mydomain.co.nz without the “mail” in front of the domain.

Is this possible

I have tried a few htaccess rewrite conditions but they dont seem to work. Not sure if I am doing something wrong.

Your assistance will be appreciated

I’m not sure all the details of the NS install as I just started tinkering.

So this suggestion may be completely wrong. This is only some thoughts and suggestions of what to check and look into. I’m sure a few other folks will jump in to provide details and/or correct my suggestions.

First question I have is why the NS is set up at mail.mydomain.co.nz instead of mydomain.co.nz?
I would have thought the latter to be the best option. Then mail.mydomain.co.nz would be for smtp and more than likely mydomain.co.nz/mail would give you a webmail interface if it doesn’t have a port number access. You would need to look into the webmail module for configuration info.

Second, if this is how you want to keep the set up, and you are running Apache, then I think the module mod_rewrite would do the redirecting.

Apache has to have mod_write enabled for this to work.

You will need to update the virtual host config to create the redirect.

1 Like

Hi @Nuke

Thank you for your reply.

I also wander why I did this when I set it up in 2019 I was advised this was best practice by some of my colleagues who were using sme server now koozali sme server.

This is how they were configuring them and advised me to do the same. I remember asking at the time why not just install it at the primary domain level and wasn’t completely satisfied with the answer but took the advice anyway.

This is the problem I am dealt with and for the most part the server is used as a home mail server so I guess I chose mail not realising the full potential of NethServer.

I was hoping unexpected visitors to mail.wrightway.nz to not see the server management page and be redirected to my public site.

I will look into the mod rewrite vhost config thanks for pointing me in the right direction.

Have a great day.

What about a simple redirect page in /var/www/html ?

1 Like

This shouldn’t be happening in any case. The server management page should be only accessible from inside your network and not open to the public. If it is available to the public, then there is a problem.

Hi @Nuke

Correct they will not be able to access the server manager on port 9090 from the wan interface unless allowed in the cockpit manager.

I meant to say I would like unexpected visitors to not see the automatically generated nethserver information page at the domain primary level which contains a link to the server manager revealing the url and port number.

Basically want visitors to my nethserver domain to be redirected to a designated vhost instead of displaying what server I am running and what port it is running on.

1 Like