Question

I have a "dummy" web site in IIS on a 2008 server that redirects users to the correct web site.

For historical reasons this box, and what everyone knows, is "mail.abc.com".

"mail" has now come to mean several other things, but people just type that name or have it bookmarked and expect to get directed to the "type of service" they are looking for.

mail.abc.com (ports 80 or 443) actually redirects to -> webmail.abc.com (port 443)

webmail contains a webportal for the users to sign into their email, but it also holds their personal web pages. These are accessed by going to ->mail.abc.com/~their_name

I want to create some type of rule that splits this into two pieces (we are splitting these two services onto 2 servers - one for the email part and one for their personal web pages)

so if you go to the generic page the redirect should goto webmail.abc.com but if there is a "~", I want to redirect to a different location => webpages.abc.com/~their_name

I was looking at HTML redirects to do this, but I'm not sure how to split the typed-in URL, the "root" URL could be easily redirected, but how would I build something for any URL that had the tilde in it?

Was it helpful?

Solution

If you are able to use .htaccess, put a file .htaccess with the following configuration in the root folder of the mail.abc.com host:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/~(.*)
RewriteRule ^(.*)$ http://webpages.abc.com/~%1 [R=302,L]
RewriteCond %{REQUEST_URI} ^(.*)
RewriteRule ^(.*)$ http://webmail.abc.com%1 [R=302,L]

What happens:

  1. Line 2 and 3 is the first set of RewriteCond and RewriteRule. The RewriteRule in the third line will redirect to http://webpages.abc.com/ only, if mail.abc.com was called with ~ in the URL segment. So if I try to open for example http://mail.abc.com/~m_eberhard I will be redirected to http://webpages.abc.com/~m_eberhard.
  2. The next set in line 4 and 5 will redirect everything else to webmail.abc.com. If I try to open mail.abc.com/asdasdasd I will be redirect to webmail.abc.com/asdasdasd
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top