Link to home
Start Free TrialLog in
Avatar of misfit139
misfit139Flag for Australia

asked on

Two URL's pointing to 1 Website - Redirect URL1 to URL2

I've just published a site to the web which staff access using https://URL-1.acme.com and it's working fine. When users access the site internally they use https://URL-2.acme.com.

To make things simpler for staff I'd like them to be able to access the site internally using either URL-1 or URL-2. I've created an internal DNS record for URL-1 to point to the web server and users can browse to the site.

The issue is the site internally is https://URL-2.acme.com with an SSL Cert of the same name bound to it and when a user browses internally using URL-1 they're getting an SSL warning due to mismatched address.

Ideally what i'd like is when a user browses to URL-1 internally it's automatically redirected to URL-2 but I've poked around and can't find anything obvious so hoping someone here can help before I break things.

Hopefully that makes sense and let me know if you need me to provide more info. Thanks in advance.
Avatar of becraig
becraig
Flag of United States of America image

URL Rewrite would be  your best bet here:
More info on URL rewrite :
http://www.surfingsuccess.com/asp/iis-url-rewrite.html


An example for you would be:
http_host matches url1 and {REMOTE_ADDR}  matches your internal ips
SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of misfit139

ASKER

Thanks for the responses guys and sorry for not getting back to you sooner. I tried the quick and dirty way suggested by Gary but you still get the Cert Warning and then when you click continue it does change the URL.

I've also installed the URL Rewrite module, rebooted the server and tried following the walkthrough but not having any luck. I have tried "redirect" and "rewrite" I've tried it from the top level of IIS and from the Website but nothing happens.

Not sure where i'm going wrong and yes becraig I still want URL-1 to be accessible to external users.
Redirect2.JPG
Redirect.JPG
Ok so here is what you need to do

1.  This first pattern is good *
2. Logical grouping should be {REMOTE_ADDR}  (This should be your internal IP address, e.g. 192.168.1.*)

Then you do the redirect URL

Send it to URL2 etc



IIsreset and test.
Hi Becraig, thanks for your reply. I've tried as you suggested but now I'm getting Page cannot be displayed, I disabled the rule and I'm then go back to getting the Cert error.

Tested from two PC's both on 192.168.160.x subnet.
Redirect3.JPG
Ok so first issue

Please double check the destination URL in the rule since the page cannot be displayed sounds like a DNS resolution error.

It is obvious the redirect based on ip works since you get a different result in the browser, please ensure you can resolve the redirect URL ;

Nslookup site2 from a command prompt.  

Second.

You will get the cert error since you are loading a site different to the one requested.
Disabled URL Rewrite rule retsart IIS
Checked the redirect URL, copied and pasted in to a browser and works.
Nslookup returns the correct IP for both URL from the same PC I tested on.
I can browse to both URL's

Enable URL Rewrite rule Restart IIS
From test PC browse to URL-1 get Cert error, click on continue and stay on URL-1 "Page cannot be displayed.
From test PC browse to URL-2 no cert error straight to Page cannot be displayed.
Nslookup still returns the IP of the Webserver on both URL's and can ping that IP.

Here is the code from the Web.config file

<rules>
                <rule name="URL-1 to URL-2" enabled="true" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REMOTE_ADDR}" pattern="192.168.*.*" />
                    </conditions>
                    <action type="Redirect" url="https://URL-2.acme.com/{R:0}" appendQueryString="true" />


Also you said "It is obvious the redirect based on ip works since you get a different result in the browser"

I actually don't think it is working, when I browse to URL-1 it remains on URL-1 after clicking on continue on Cert error page. That is with the Rule enabled or disabled, the only difference being the page is displayed when the rule is disabled.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your problem here as indicated above is the SSL redirect.  

There are ways to resolve that, which will allow URL rewrite to work.
If like me you are trying to redirect one SSL URL to a second SSL URL and the second URL is the only SAN valid on the Certificate. Then URL Rewrite doesn't work because the SSL connection fails to establish due to the Certificate mismatch. In a different situation both the other guys answers would be more beneficial.