Solved

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

Posted on 2014-04-02
9
311 Views
Last Modified: 2014-04-08
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("~", "-");
0
Comment
Question by:shay911
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 20

Expert Comment

by:edster9999
ID: 39973521
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 :)
0
 

Author Comment

by:shay911
ID: 39973529
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
0
 

Author Comment

by:shay911
ID: 39973535
www.airbnb.com

www.airbnb.co.uk 

they are using cname it seems.
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 20

Expert Comment

by:edster9999
ID: 39973687
They may well be - but that doesn't make it right :)
0
 
LVL 20

Expert Comment

by:edster9999
ID: 39973690
Both of their CNAMES go to cloud services.  Not between domains.
0
 

Author Comment

by:shay911
ID: 39973695
Thanks, so how do i actually go about doing what you say?
0
 
LVL 20

Accepted Solution

by:
edster9999 earned 500 total points
ID: 39973754
well I'm not sure it is what you want at all.

In my one - when you go to - www.domain.co.uk
the screen flashes and you get forwarded onto www.domain.com

I'm guessing you want both to run separately - just having the same content ?
0
 

Author Comment

by:shay911
ID: 39973787
yes absolutely! i want to run both of them seperately
0
 

Author Closing Comment

by:shay911
ID: 39985344
Accepting it
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Load XML element 3 43
How do i create a simple array in a public class? 6 35
SSIS Column mapping 5 40
XML XDocument extract - Keeping a node list like a menu path 8 33
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question