0

We have some domains that redirect to our main site but have the url masked.

For e.g. you visit http://foo.com and you are redirected to http://bar.com but the address bar remains http://foo.com.

I want to be able to modify the url shown by way of a redirect or similar to the actual url you are viewing (un-masked).

I thought something like this would work (and it does when running on localhost) but on the live site the url is still masked.

In Global.asa.vb:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    Dim url As String = HttpContext.Current.Request.Url.ToString
    If Not url.ToLower.Contains("foo.com") Then
        resp.Redirect("http://bar.com" + HttpContext.Current.Request.Path, True)
        Exit Sub
    End If
End Sub
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • Unsure why local/live would differ...IMHO, probably better handled by [IIS Url Rewrite](http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module), or if IIS6/W2k3, [you can do same in IIS Manager](http://technet.microsoft.com/en-us/library/cc737576.aspx). Hth... – EdSF Sep 11 '14 at 15:27
  • @EdSF - by locally I mean IIS express works in the fact that the url is localhost (no masking is going on) but on the live site I redirect and the mask still persists – Matt Wilko Sep 11 '14 at 15:28
  • A `Redirect` (301/302) shouldn't "mask". Not much of an IT guy- would there probably be some ["domain masking"](https://support.godaddy.com/help/article/422/forwarding-or-masking-your-domain-name) setting going on? – EdSF Sep 11 '14 at 15:43

0 Answers0