0

I have issue here regarding URL Case Sensitivity. i.e. we show results for http://www.starmicronics.com/Printer/Home.aspx (the actual page that exists) as well as for http://www.starmicronics.com/printer/home.aspx (a second page and folder listed with lower case names that actually doesn’t exist).

I want to Convert second url to fist url automatically. How to do that. Any suggestion is highly appreciated.

Thanks

Dwarika

Dwarika Nath
  • 13
  • 1
  • 7
  • http://stackoverflow.com/questions/5811021/how-to-enable-case-sensitivity-under-iis-express – Nagaraj S Jan 03 '14 at 05:56
  • If I get it right, you want to do the exact opposite. You want to make the URL handling, **case insensitive** so that the URL would be served, even when it is written with no capital letters. Right? – Pantelis Natsiavas Jan 03 '14 at 06:10
  • Pantelis Natsiavas, I want the url case sensitive so that when user type small case it should show automatically redirect to upper case url. – Dwarika Nath Jan 03 '14 at 06:45

2 Answers2

0

I am not sure what language you are using. But if you are doing this on the server side in C# you could use a regex:

static void Main( string[] args )
{
    //Your test string
    string test = @"http://www.starmicronics.com/printer/home.aspx";
    var result = Regex.Replace( test, "(?<=[^/]/)[^/]", delegate( Match match )
    {
        string v = match.ToString();
        return char.ToUpper(v[0]) + v.Substring(1);
    });
    Console.WriteLine(result); //http:www.starmicronics.com/Printer/Home.aspx
}

Explanation of Regex (?<=[^/]/)[^/]

  • A character that is not a / preceded by a / that itself is not preceeded by a /
  • [^/] not a /
  • ?<= a positive look behind

This is a simple approach that would satisfy your example.

acarlon
  • 16,764
  • 7
  • 75
  • 94
  • Hi acarlon, Thanks for the reply but one more question How to display the correct url in users's browser. Thanks Dwarika – Dwarika Nath Jan 03 '14 at 06:42
  • @DwarikaNath: An example and discussion for asp.net mvc: http://stackoverflow.com/questions/9518064/asp-net-mvc-3-case-sensitive-urls – acarlon Jan 03 '14 at 06:55
  • That link is the inverse of what you want to do, but the same applies. You would need to receive the request and redirect to the corrected URL. Then the user would see the correct URL in their browser. – acarlon Jan 03 '14 at 07:02
0

Please try ISAPI_Rewrite 3, it may help you. you need to write rule for it.

http://www.helicontech.com/isapi_rewrite/

Manoj Mevada
  • 649
  • 4
  • 7