Link to home
Start Free TrialLog in
Avatar of shay911
shay911

asked on

Did a cname to my domain.co.uk to domain.com.. global.asax redirect not working

Ok i have a

domain.com and domain.co.uk. Domain.com is my real domain with physical content.

I made a cname so domain.co.uk visitors see all data from domain.com

Now i am doing some redirects in my search in global.asax and seems everything is working on my co.uk domain except for the search.

here is the relative code from the global.asax file

// If the dummy page is hit, then it means we want to add another item
    // in cache
    string url = HttpContext.Current.Request.Url.ToString().ToLower();
    if (url.Contains("/property/s/") && url.Contains("localhost"))
    {
       FakeUrlCheck(4);
    }
    else (url.Contains("domain.com/property/s/") && url.Contains("domain.com/property/s/"))
    {
        FakeUrlCheck(4);        
    }
  else if (url.Contains("www.domain.co.uk/property/s/"))
    {
        FakeUrlCheck(4);        
    }


}
void FakeUrlCheck(int length)
{

    string AbsUrl = HttpContext.Current.Request.Url.AbsolutePath;
    string[] urlInfo404 = AbsUrl.Split('/');
    if (AbsUrl.ToLower().Contains("/property/s/") && !File.Exists(Request.PhysicalPath) && !AbsUrl.ToLower().Contains("property/default.aspx") && urlInfo404.Length == length)
    {
        string location = urlInfo404[length -1];
        StringBuilder sbParams = new StringBuilder();
        sbParams.Append("?AL=");
        //if (location.Contains(", "))
        //    location = location.Replace(", ", "--");
        //if (location.Contains(" - "))
        //    location = location.Replace(" - ", "--");
        //if (location.Contains(" "))
        //    location = location.Replace(" ", "--");

        if (location.Contains("--"))
            location = location.Replace("--", ", ");
        if (location.Contains("-"))
            location = location.Replace("-", " ");
        //if (location.Contains(" - "))
        //    location = location.Replace("~", "-");
Avatar of edster9999
edster9999
Flag of Ireland image

CNames are designed to give an alias to a domain name.

for example you could setup a domain name

mail.domain.com ---> IP address of 10.20.30.40

then you could setup a cname like this :
webmail.domain.com ---> mail.domain.com

The rules do not state that you cannot cross from one domain to another but it would be seen as bad practice.
- It looks ugly
- It will end up eating PR ranking in search engines and put you down the page
- It is harder to troubleshoot if there are issues later in life.

A far better way of doing this is to setup a empty web site.  A single page will be served to any page request. It will give a http 301 error and redirect to the main page.

If you do this it will fix all of the things listed (by me) above and you can also get rd of most of the domain url checking code :)
Avatar of shay911
shay911

ASKER

How do i do that? a 301 redirect would redirect .co.uk to .com that is not some thing i want, or you are talking about some thing else? sorry not very savvy! thanks
Avatar of shay911

ASKER

www.airbnb.com

www.airbnb.co.uk 

they are using cname it seems.
They may well be - but that doesn't make it right :)
Both of their CNAMES go to cloud services.  Not between domains.
Avatar of shay911

ASKER

Thanks, so how do i actually go about doing what you say?
ASKER CERTIFIED SOLUTION
Avatar of edster9999
edster9999
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
Avatar of shay911

ASKER

yes absolutely! i want to run both of them seperately
Avatar of shay911

ASKER

Accepting it