Intranet HostName forwarding

Hello,

I have a virtualmin that I’m using on the intranet.

I want to try to make the following work:

I have a subserver which is named something like monkey.treasureisland.com which is not a real domain which I own, it’s in the intranet so I don’t really care.

In my windows host file I can add something like

192.168.2.55 monkey.treasureisland.com

but it’s a little unrealistic to expect coworkers to remember such a convoluted url

The hostfile allows me to use something like:
192.168.2.55 intranet

However monkey.treasureisland.com is on port 90 so without the port number it just brings me to a you are forbidden to view this page.

Would it be possible to make a redirect in the server that is based on the address in the addressbar and not an actual domain set up in the server

Howdy,

Which ever domain is actually being loaded when you see that “Forbidden” message – if you place a .htaccess file in the DocumentRoot of that domain, you could then perform a redirect based on what’s in the domain.

For the contents of that .htaccess file, something like this should work:

RewriteEngine On RewriteCond %{HTTP_HOST} ^monkey$ [OR] RewriteCond %{HTTP_HOST} ^monkey.treasureisland.com$ RewriteRule (.*)$ http://monkey.treasureisland.com:90/$1 [R=301,L]

Worked like a charm, don’t know why I didn’t think of that.

I guess I’m so used to working within the Webmin UI haha. :wink: