Intranet HostName forwarding

3 posts / 0 new
Last post
#1 Wed, 11/13/2013 - 07:53
prince_mallow

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

Wed, 11/13/2013 - 08:29
andreychek

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:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^monkey$ [OR]
  RewriteCond %{HTTP_HOST} ^monkey.treasureisland.com$
  RewriteRule (.*)$ http://monkey.treasureisland.com:90/$1 [R=301,L]
</IfModule>
Fri, 11/15/2013 - 15:50
prince_mallow

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. ;)

Topic locked