<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://v900u039rux.maximumasp.com/Web/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Raheel Hussain : URL Rewriting</title><link>http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/tags/URL+Rewriting/default.aspx</link><description>Tags: URL Rewriting</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP2 (Build: 20611.960)</generator><item><title>URL Rewriting (Part 3)</title><link>http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/2007/10/03/url-rewriting-part-3.aspx</link><pubDate>Wed, 03 Oct 2007 08:13:00 GMT</pubDate><guid isPermaLink="false">3790bee0-d05b-4b84-a272-3ed522a0473a:72</guid><dc:creator>Raheel Hussain</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://v900u039rux.maximumasp.com/Web/blogs/raheel/rsscomments.aspx?PostID=72</wfw:commentRss><comments>http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/2007/10/03/url-rewriting-part-3.aspx#comments</comments><description>&lt;p&gt;This is offcourse linked to the last blog for URL Rewritting, some technical bits to be shared,&amp;nbsp;a little enhancement to the previous technique to URL Rewriting and also an issue which could be a limitation (or more likely that a I&amp;#39;m unable to findout solution to it) for the way I implemented the URL Rewritting.&lt;br /&gt;&lt;br /&gt;I had implemented the URLs with a directory structure strategy.&lt;br /&gt;i.e.&amp;nbsp; &lt;a href="http://localhost:3648/Teams/"&gt;http://localhost:3648/Teams/&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://localhost:3648/Teams/Pakistan/"&gt;http://localhost:3648/Teams/Pakistan/&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://localhost:3648/Teams/India/"&gt;http://localhost:3648/Teams/India/&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://localhost:3648/Teams/Sri-Lanka/"&gt;http://localhost:3648/Teams/Sri-Lanka/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;While going into live environment, I faced an issue and which (so far) I&amp;#39;m unable to resolve...&lt;br /&gt;&lt;br /&gt;The issue was that when the page was redirected to a URL (say &lt;a href="http://localhost:3648/Teams/Pakistan/"&gt;http://localhost:3648/Teams/Pakistan/&lt;/a&gt;)&amp;nbsp; the images to be displayed in the page took the different relative path for the image URL and hence not displaying the picture.&lt;br /&gt;&lt;br /&gt;For example: &lt;br /&gt;If the image path was &amp;quot;images/testimage.jpg&amp;quot; then after URL Rewritting, it became as &amp;quot;Pakistan/images/testimage.jpg&amp;quot; and therefore misguiding the browser to retreive the image from a non-existent and wrong directory...&lt;br /&gt;&lt;br /&gt;This led me to change my strategy towards URL Rewritting technique, and I rather switched to a slighly different URL Rewritting bit.&lt;br /&gt;&lt;br /&gt;i.e.&amp;nbsp; &lt;a href="http://localhost:3648/Teams.aspx"&gt;http://localhost:3648/Teams.aspx&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://localhost:3648/Pakistan.aspx"&gt;http://localhost:3648/Pakistan.aspx&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://localhost:3648/India.aspx"&gt;http://localhost:3648/India.aspx&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://localhost:3648/Sri-Lanka.aspx"&gt;http://localhost:3648/Sri-Lanka.aspx&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://localhost:3648/Hockey.htm"&gt;http://localhost:3648/Hockey.htm&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://localhost:3648/Tennis.shtml"&gt;http://localhost:3648/Tennis.shtml&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;From the SEO (Search Engine Optimization) point of view, this is still very useful URL.&lt;br /&gt;&lt;br /&gt;I had to do the following change in the &amp;quot;&lt;font size="2"&gt;Application_BeginRequest&amp;quot;&amp;nbsp;event&amp;nbsp;in &lt;/font&gt;global.asax file&lt;br /&gt;&lt;br /&gt;Old Code:&lt;/p&gt;
&lt;div style="BORDER-RIGHT:1px solid;BORDER-TOP:1px solid;OVERFLOW:scroll;BORDER-LEFT:1px solid;WIDTH:546px;BORDER-BOTTOM:1px solid;BACKGROUND-COLOR:#f5f5f5;"&gt;&lt;pre&gt;    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        Dim strPath As String = Request.Url.ToString()
        If strPath.Contains(&amp;quot;Pakistan/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=1&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;India/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=2&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Sri-Lanka/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=3&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Cricket/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=1&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Football/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=2&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Tennis/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=3&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Hockey/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=4&amp;quot;)
        Else
            Context.RewritePath(&amp;quot;~/default.aspx&amp;quot;)
        End If
    End Sub
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;New Code:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div style="BORDER-RIGHT:1px solid;BORDER-TOP:1px solid;OVERFLOW:scroll;BORDER-LEFT:1px solid;WIDTH:546px;BORDER-BOTTOM:1px solid;BACKGROUND-COLOR:#f5f5f5;"&gt;&lt;pre&gt;    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        Dim strPath As String = Request.Url.ToString()
        If strPath.Contains(&amp;quot;Pakistan.aspx&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=1&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;India.aspx&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=2&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Sri-Lanka.aspx&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=3&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Cricket.aspx&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=1&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Football.aspx&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=2&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Tennis.shtml&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=3&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Hockey.htm&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=4&amp;quot;)
        End If
    End Sub
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Also, with the changes in the URLs i.e. Hockey.htm or India.aspx, you may also had noticed that I&amp;#39;ve removed the else condition, that was because, while when the browser is reading the image file, this function is called and&amp;nbsp;the control directly goes to the else condition, while reading the image, and that lead the image URL to parse as default.aspx&lt;br /&gt;&lt;br /&gt;&amp;nbsp;Following is the&amp;nbsp;snapshot of the&amp;nbsp;application with the folder technique&lt;/p&gt;
&lt;div style="OVERFLOW:scroll;WIDTH:546px;"&gt;&lt;a href="http://yukonizer.com/Web/blogs/raheel/url_test_1.jpg"&gt;&lt;img src="http://yukonizer.com/Web/blogs/raheel/url_test_1.jpg" border="0" alt="" /&gt;&lt;/a&gt; &lt;/div&gt;
&lt;p&gt;Following is the new snapshot of the application with the URL (without folder)&lt;/p&gt;
&lt;div style="OVERFLOW:scroll;WIDTH:546px;"&gt;&lt;a href="http://yukonizer.com/Web/blogs/raheel/url_test_w_url.gif"&gt;&lt;img src="http://yukonizer.com/Web/blogs/raheel/url_test_w_url.gif" border="0" alt="" /&gt;&lt;/a&gt; &lt;/div&gt;
&lt;p&gt;&lt;br /&gt;With this strategy also, the limitations remain the same as discussed in previous post. &lt;br /&gt;But as far as SEO is concerned this way or the previous one, we can acheive our targets.&lt;br /&gt;&lt;br /&gt;The Server.Execute or Server.Transfer methods for instance, can be utilized at places where necessary but they would definetely show up with the original URL which was masked (re-written) but since the Top Level Menus of the website are using &amp;quot;response.redirect&amp;quot; method, it will still serve the purpose.&lt;br /&gt;&lt;br /&gt;The project is the same consists of the following files&lt;br /&gt;&lt;br /&gt;Global.asax&lt;br /&gt;MasterPage.master&lt;br /&gt;default.aspx&lt;br /&gt;teampage.aspx&amp;nbsp;&lt;br /&gt;sportspage.aspx&lt;br /&gt;web.config&lt;br /&gt;&lt;br /&gt;The master page contains the menus (Four link buttons) each of which redirects to a different page (A dummy URL).&lt;br /&gt;&lt;br /&gt;OLD Example Code: &lt;/p&gt;
&lt;div style="BORDER-RIGHT:1px solid;BORDER-TOP:1px solid;OVERFLOW:scroll;BORDER-LEFT:1px solid;WIDTH:546px;BORDER-BOTTOM:1px solid;BACKGROUND-COLOR:#f5f5f5;"&gt;&lt;pre&gt;    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Response.Redirect(&amp;quot;~/Cricket/&amp;quot;)
    End Sub

    Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton2.Click
        Response.Redirect(&amp;quot;~/Football/&amp;quot;)
    End Sub

    Protected Sub LinkButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton3.Click
        Response.Redirect(&amp;quot;~/Tennis/&amp;quot;)
    End Sub

    Protected Sub LinkButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton4.Click
        Response.Redirect(&amp;quot;~/Hockey/&amp;quot;)
    End Sub
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;New Example Code:&lt;/p&gt;
&lt;div style="BORDER-RIGHT:1px solid;BORDER-TOP:1px solid;OVERFLOW:scroll;BORDER-LEFT:1px solid;WIDTH:546px;BORDER-BOTTOM:1px solid;BACKGROUND-COLOR:#f5f5f5;"&gt;&lt;pre&gt;    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Response.Redirect(&amp;quot;~/Cricket.aspx&amp;quot;)
    End Sub

    Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton2.Click
        Response.Redirect(&amp;quot;~/Football.aspx&amp;quot;)
    End Sub

    Protected Sub LinkButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton3.Click
        Response.Redirect(&amp;quot;~/Tennis.shtml&amp;quot;)
    End Sub

    Protected Sub LinkButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton4.Click
        Response.Redirect(&amp;quot;~/Hockey.htm&amp;quot;)
    End Sub
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;------------------------&lt;br /&gt;&lt;br /&gt;Although, this is one other way for implementing the URL re-writting, I&amp;#39;ll will welcome to some one of you would find a solve to it to help me out &lt;br /&gt;as well as I will be searching for it, and will update you if I find some resolution to that.&lt;br /&gt;&lt;br /&gt;The change I did in the existing project can be downloaded by clicking &lt;a href="http://dnfug.com/Web/blogs/raheel/URL_TEST_updated.zip"&gt;URL_TEST_updated.zip&lt;/a&gt;&lt;br /&gt;------------------------&lt;br /&gt;&lt;br /&gt;There are other ways for the URL rewriting two, while IIS7 provides much better functionalities supporting the pageless URL re-writing &lt;br /&gt;&lt;br /&gt;You can have a look at &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx"&gt;ScottGu&amp;#39;s Blog&lt;/a&gt; to have an indepth view of what other ways are there for URL re-writing as well.&lt;br /&gt;Othere Useful Links are &lt;br /&gt;&lt;a href="http://www.asp101.com/articles/matteo/urlrewriting/default.asp"&gt;http://www.asp101.com/articles/matteo/urlrewriting/default.asp&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.mattcutts.com/blog/asp-net-2-and-url-rewriting-sometimes-harmful/"&gt;http://www.mattcutts.com/blog/asp-net-2-and-url-rewriting-sometimes-harmful/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Cheers ! &lt;br /&gt;&lt;br /&gt;raheel Hussain&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://v900u039rux.maximumasp.com/Web/aggbug.aspx?PostID=72" width="1" height="1"&gt;</description><category domain="http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/tags/URL+Rewriting/default.aspx">URL Rewriting</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/tags/SEO/default.aspx">SEO</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/tags/Global_2E00_asax/default.aspx">Global.asax</category></item><item><title>URL Rewriting (Part 2)</title><link>http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/2007/07/23/url-rewriting-part-2.aspx</link><pubDate>Tue, 24 Jul 2007 00:51:00 GMT</pubDate><guid isPermaLink="false">3790bee0-d05b-4b84-a272-3ed522a0473a:28</guid><dc:creator>Raheel Hussain</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://v900u039rux.maximumasp.com/Web/blogs/raheel/rsscomments.aspx?PostID=28</wfw:commentRss><comments>http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/2007/07/23/url-rewriting-part-2.aspx#comments</comments><description>URL rewriting can be performed by many techniques. Basically you need to decide the technique&amp;nbsp;according of your requirements.&lt;br /&gt;&lt;br /&gt;Every technique has its&amp;nbsp;ups and downs.&amp;nbsp;I tried using the HTTPModule approach by dynamically re-writing the URL. &lt;br /&gt;&lt;br /&gt;This technique involves the usage of the&amp;nbsp; &amp;quot;&lt;font size="2"&gt;Application_BeginRequest&amp;quot; event&amp;nbsp;in &lt;/font&gt;global.asax file&lt;br /&gt;&lt;font size="2"&gt;&lt;br /&gt;Whenever a file is requested, this event gets fired, before the requested page events.&amp;nbsp;In the&amp;nbsp;Application_BeginRequest, we need to check the&amp;nbsp;requested URL and on the basis of that, re-write the URL with the HttpContext&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;Following is the snapshot of the&amp;nbsp;application.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div style="OVERFLOW:scroll;WIDTH:546px;"&gt;&lt;a href="http://yukonizer.com/Web/blogs/raheel/url_test_1.jpg"&gt;&lt;img src="http://yukonizer.com/Web/blogs/raheel/url_test_1.jpg" border="0" alt="" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;However, there are some limitations. 
&lt;ol&gt;
&lt;li&gt;You cannot use server.transfer or server.execute methods.&lt;br /&gt;The Server.Transfer require a relative path as well as the Server.Execute. Hense a virtual path within the virtual directory of application server is required.&lt;br /&gt;You can notice this when you open the Braces to put the argument i.e. the path of the page that it asks for Path, while if you do the same with &lt;br /&gt;response.redirect, it rather ask you for the URL. Therefore, a dummy address cannot be used with these two methods like what we do with response.redirect.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;The normal Hyperlink controls cannot be used, instead, you need to use Linkbuttons or Buttons with response.redirect in their code&lt;br /&gt;The reason for this is mainly because&amp;nbsp;they hyperlinks doesnt cause the requested URL to change everytime they are clicked,while on the other hand with &lt;br /&gt;response.redirect&amp;nbsp;command&amp;nbsp;in the code behind of the linkbutton tries accessing a page with its exact path.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;for example:&lt;br /&gt;by using the link button you would see the URL in the address bar as&lt;br /&gt;&lt;a href="http://localhost/myapplication/Products/"&gt;http://localhost/myapplication/Products/&lt;/a&gt;&lt;br /&gt;next time clicking on the same linkbutton will cause the same URL to be displayed.&lt;br /&gt;&lt;br /&gt;on the other hand Hyperlink is treated differently with the URL rewriting technique&lt;br /&gt;Hyperlink provides the existing URL in the address bar and the code concatenates another URL rewrite string with it.&lt;br /&gt;Hense the URL in the address bar would end UP like as follows:&lt;br /&gt;&lt;a href="http://localhost/myapplication/Products/Products/Products"&gt;http://localhost/myapplication/Products/Products/Products&lt;/a&gt; ............... and so on with every click.&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;The project consists of the following files&lt;br /&gt;&lt;br /&gt;Global.asax&lt;br /&gt;MasterPage.master&lt;br /&gt;default.aspx&lt;br /&gt;teampage.aspx&amp;nbsp;&lt;br /&gt;sportspage.aspx&lt;br /&gt;web.config&lt;br /&gt;&lt;br /&gt;The master page contains the menus (Four link buttons) each of which redirects to a different page (A dummy URL).&lt;br /&gt;&lt;br /&gt;For Example: &lt;/p&gt;
&lt;div style="BORDER-RIGHT:1px solid;BORDER-TOP:1px solid;OVERFLOW:scroll;BORDER-LEFT:1px solid;WIDTH:546px;BORDER-BOTTOM:1px solid;BACKGROUND-COLOR:#f5f5f5;"&gt;&lt;pre&gt;    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Response.Redirect(&amp;quot;~/Cricket/&amp;quot;)
    End Sub

    Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton2.Click
        Response.Redirect(&amp;quot;~/Football/&amp;quot;)
    End Sub

    Protected Sub LinkButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton3.Click
        Response.Redirect(&amp;quot;~/Tennis/&amp;quot;)
    End Sub

    Protected Sub LinkButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton4.Click
        Response.Redirect(&amp;quot;~/Hockey/&amp;quot;)
    End Sub
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;None of the folder (the redirected url or folder)&amp;nbsp;above in the response.redirect, actually exists.&lt;br /&gt;&lt;br /&gt;While in the global.asax file following code is to be implemented:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div style="BORDER-RIGHT:1px solid;BORDER-TOP:1px solid;OVERFLOW:scroll;BORDER-LEFT:1px solid;WIDTH:546px;BORDER-BOTTOM:1px solid;BACKGROUND-COLOR:#f5f5f5;"&gt;&lt;pre&gt;    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        Dim strPath As String = Request.Url.ToString()
        If strPath.Contains(&amp;quot;Pakistan/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=1&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;India/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=2&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Sri-Lanka/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/teampage.aspx?TeamID=3&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Cricket/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=1&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Football/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=2&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Tennis/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=3&amp;quot;)
        ElseIf strPath.Contains(&amp;quot;Hockey/&amp;quot;) Then
            Context.RewritePath(&amp;quot;~/sportspage.aspx?SportID=4&amp;quot;)
        Else
            Context.RewritePath(&amp;quot;~/default.aspx&amp;quot;)
        End If
    End Sub
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you can see that, upon detecting the requested URLs which are dummy to show to the user, the context.rewritepath() method to actually determine that what is the underlying page to be redirected.&lt;br /&gt;&lt;br /&gt;The querystrings which are not visible to the user in the address bar are used the same way as they are to be used.&lt;br /&gt;&lt;br /&gt;You can download the code by clicking on the following link.&lt;a href="http://yukonizer.com/Web/blogs/raheel/URL_TEST.zip"&gt;URL Rewriting Demo&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;------------------------&lt;br /&gt;&lt;br /&gt;There are other ways for the URL rewriting two, while IIS7 provides much better functionalities supporting the pageless URL re-writing &lt;br /&gt;&lt;br /&gt;You can have a look at &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx"&gt;ScottGu&amp;#39;s Blog&lt;/a&gt; to have an indepth view of what other ways are there for URL re-writing as well.&lt;br /&gt;Othere Useful Links are &lt;br /&gt;&lt;a href="http://www.asp101.com/articles/matteo/urlrewriting/default.asp"&gt;http://www.asp101.com/articles/matteo/urlrewriting/default.asp&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.mattcutts.com/blog/asp-net-2-and-url-rewriting-sometimes-harmful/"&gt;http://www.mattcutts.com/blog/asp-net-2-and-url-rewriting-sometimes-harmful/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Cheers ! &lt;br /&gt;&lt;br /&gt;raheel Hussain&lt;/p&gt;&lt;br /&gt;&lt;img src="http://v900u039rux.maximumasp.com/Web/aggbug.aspx?PostID=28" width="1" height="1"&gt;</description><category domain="http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/tags/URL+Rewriting/default.aspx">URL Rewriting</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/tags/SEO/default.aspx">SEO</category></item><item><title>URL Rewriting (Part 1)</title><link>http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/2007/07/22/url-rewriting-part-1.aspx</link><pubDate>Sun, 22 Jul 2007 08:22:00 GMT</pubDate><guid isPermaLink="false">3790bee0-d05b-4b84-a272-3ed522a0473a:25</guid><dc:creator>Raheel Hussain</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://v900u039rux.maximumasp.com/Web/blogs/raheel/rsscomments.aspx?PostID=25</wfw:commentRss><comments>http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/2007/07/22/url-rewriting-part-1.aspx#comments</comments><description>&lt;span style="FONT-FAMILY:Verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;During one of the projects I did, I was asked for having URLs like YAHOO or GOOGLE for an intranet application &lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;and believe me that before that requirement came out, although I knew that there would&amp;#39;ve been some technology, but never bothered to check that out.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Since now I&amp;#39;ve already done it, let me explore in my blog what I&amp;#39;ve learnt so far, as well as your comments and views are most welcome, and even the corrections.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;u&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;URL REWRITING&lt;/span&gt;&lt;/u&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt; is a technique through which you rename/re-write the URLs which are displayed in the web browser&amp;#39;s address bar.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;There are many advantages of URL rewriting technique.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Following are the listed advantages of the URL re-writing: &lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;1 - Simplicity.&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;2 - Security &amp;amp; Hiding the Technology&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;3 - SEO (Search Engine Optimization)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;(Simplicity) Simplified URLs: &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Consider a following URL &lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;&lt;a href="http://websitename.com/products/productindex.aspx?flag=y&amp;amp;date1=120107&amp;amp;date2=150107&amp;amp;tabid=5&amp;amp;hidepicture=true"&gt;http://websitename.com/products/productindex.aspx?flag=y&amp;amp;date1=120107&amp;amp;date2=150107&amp;amp;tabid=5&amp;amp;hidepicture=true&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;If the above URL goes changed to the following...&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;&lt;a href="http://websitename.com/products/listings.apx"&gt;http://websitename.com/products/listings.apx&lt;/a&gt;&amp;nbsp; ...... then wouldn’t that be fantastic ??&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;This is an easy to remember as well as simple URL, and we can count it as a plus-point of URL re-writing.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Security &amp;amp; Hiding the Technology:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Many of you have probably noticed that the dynamic pages hosted by Yahoo or even Google have no extensions for the pages like &lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;mypage.aspx or products.asp, etc. but you can see .htm on Google at some places, where there are some static content coming through the&lt;br /&gt;CMS (may be).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;There are many reasons to it, simply it can be said that the extensions of the pages, provide way for the hackers and let them think what they can do. &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;As well as the query strings can also help them out in different ways.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;SEO (Search Engine Optimization):&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;SEO is a very important base for the success of any website (of the business). And URL rewriting is one very strong aspect of it. Lets try this out with a small example.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Go to http://www.google.com/ and type &amp;quot;Football&amp;quot; in the search box.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;You will notice the following results.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Listed at 1st Place&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: &lt;a href="http://www.football.com/"&gt;www.football.com/&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Listed at 2nd Place : &lt;a href="http://news.bbc.co.uk/sport1/hi/football/default.stm"&gt;http://news.bbc.co.uk/sport1/hi/football/default.stm&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Listed at 3rd Place : &lt;a href="http://en.wikipedia.org/wiki/Football_(soccer"&gt;http://en.wikipedia.org/wiki/Football_(soccer&lt;/a&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;Listed at 3rd Place : &lt;a href="http://en.wikipedia.org/wiki/American_football"&gt;http://en.wikipedia.org/wiki/American_football&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;&lt;/span&gt;
&lt;p class="MsoNormal" style="MARGIN:0cm 0cm 0pt;"&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;In the above results, I guess there is very little to explain about, as you can notice the URLs. Not necessarily all the pages which came out of the search are static, but static pages are always top in the queue for search engine as compare to the dynamic pages, I cannot change it for you :)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;But if we do have a search engine friendly URL, it would definitely find its place up on the top 10 or at least top 15.&lt;br /&gt;&lt;br /&gt;In my next&amp;nbsp;blog I would&amp;nbsp;provide some working examples...&lt;br /&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="FONT-FAMILY:Verdana;"&gt;
&lt;p&gt;STAY TUNED.......................&lt;br /&gt;&lt;br /&gt;cheers ! &lt;br /&gt;&lt;br /&gt;raheel Hussain&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;img src="http://v900u039rux.maximumasp.com/Web/aggbug.aspx?PostID=25" width="1" height="1"&gt;</description><category domain="http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/tags/URL+Rewriting/default.aspx">URL Rewriting</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/raheel/archive/tags/SEO/default.aspx">SEO</category></item></channel></rss>