locked
How can i rewrite my URL in another format RRS feed

  • Question

  • User360451555 posted

    Hey guys, how u doin? hop u are all aiight....

    I have a problem with trying to rewrite my url to another format.......

    I have configured my Intelligencia.UrlRewriter.dll in my Bin folder.....i want to then rewrite my URL from one format to another

    ~/ERP/StudentDetails.aspx?RegNo=107-063061-00055 to ~/ERP/StudentDetails.aspx/107-063061-00055.aspx or to another suitable format.


    Can anyone tell me how to go about it?

    Sunday, February 21, 2010 9:12 AM

Answers

  • User360451555 posted

    Hey..thanks....i loved nestle-family website....it really looks soo juicy.....felt thirsty when i visited it.....

    Anyways.....i really thnk you guys for all the knowledge u are giving me...But i never undestood how to really implement wat i require...dnt knw if am using the wrong english to elaborate myself.

    I tried to browse my server with the New URL (Rewritten URL) and i got the page i requested and that was

    ~/ERP/StudentDetails/107-063061-00055.aspx. But when am going through my links and fall hover onto that link especially from a GridView, i get the Old URL displaying in the Status bar of my browser....when i click onto that link furthermore, i get the old URL and not the new URL in the Address Bar.

    So how can i ensure that all the links that Map to the Old URL are actually turned into the New URL....its true i dnt want the OLD URL to appear anywhere. How can i make the Old URL vanish completly and it will be known to only me.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 22, 2010 3:26 AM
  • User845932231 posted

    Yes I well undestood the question..

    What I am trying to tell is you need to change the menu links to the new pattern..

    if you have a menu with link like following

    <a runat="server" href="~/ERP/StudentDetails.aspx?RegNo=107-063061-00055">TEST</a>

    you need to change it like following

    <a runat="server" href="~/ERP/StudentDetails/107-063061-00055.aspx">TEST</a>

    If you are dynamically generating your menu links, you need to re-write the program to out put the links in the new pattern...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 23, 2010 5:06 AM

All replies

  • User845932231 posted

    Its pretty easy to do URL Rewriting using Intelligencia.UrlRewriter..

    You need to configure the reqriter properly in web.config after adding refernce to the DLL in your bin folder using Add Reference option in the VS solution explorer..

    Foloow the steps here to make the configuration

    http://urlrewriter.net/index.php/support/configuration

    The step 6 is the configuration of URL patterns.. here you need to set the pattern as you want..

    You can try the pattern as follows to meet your need

    <rewriter>
    <rewrite url="/StudentDetails/(.+).aspx" to="/StudentDetails.aspx?RegNo=$1" />
    </rewriter>
    Sunday, February 21, 2010 12:42 PM
  • User360451555 posted

    Hello...how u doin....thks for the reply.......av really tried to implement what you wrote but all in vain. Can you please send me a zipped file with the implementation so i see exactly what to apply where.....am kinda confused....av tried to learn about Regular expressions but all in vain......i want to really learn soo mch about this URL Rewriting so that i apply to in my security platform....

    i'l be very happy if you can do this for me


    Sunday, February 21, 2010 3:36 PM
  • User360451555 posted

    Hi...i have applied the rewrites as you wrote them but still nothing changes to my URL. They still exist wit the old format as in

    ~/ERP/StudentDetails.aspx/RegNo=107-063061-00055. What do you think am missing......u have applied the following to my web.config

    <configSections>

              <section name="rewriter" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>

        <section name="rewriter" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>


    </configSections>

    .......

    <rewriter>

        <rewrite url="^/tags/(.+)" to="/tagcloud.aspx?tag=$1" />

        <rewrite url="/StudentDetails/(.+).aspx" to="/StudentDetails.aspx?RegNo=$1" />

    </rewriter>

    ...........................

    <httpModules>

          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

          <add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" name="UrlRewriter" />

    </httpModules>

    ////////////////////////////////////////////////////////////////////////////////////////////

    av also added the following dll to my Bin folder : Intelligencia.UrlRewriter.dll

    Then can someone please tell me why my URL are not getting rewritten?


    Sunday, February 21, 2010 4:45 PM
  • User845932231 posted

    If I understand correctly,, you made all the settings but trying to browse with the old URL itself.. 

    URL Rewriting does not mean a url will get rewrite to something else automatically.. but what it means is a (rewrited) url will work as the orginal url when you try to browse...

    If you have a URL http://www.yoursite.com/ERP/StudentDetails.aspx?RegNo=107-063061-00055 and if it work properly..

    try the following url (after making all the correct configuration settings - that you already did I think)

    http://www.yoursite.com/ERP/StudentDetails/107-063061-00055.aspx


    It will work perfectly if you understand what is url rewriting and if you make the settings proper.. I have used the same URL rewriter for some huge projects like http://www.nestle-family.com/english/

    If you click on any of the Healthy Living articles shown in the middle part or any of the recipe thumbnails shown in the left part.. you will see a rewrited SEO friendly url..


    Monday, February 22, 2010 12:01 AM
  • User845932231 posted

    Also please note that the follwing line in the configuration can be removed

    <rewrite url="^/tags/(.+)" to="/tagcloud.aspx?tag=$1" />

    they just added it for demonstration in the document.. you need the next line.. which is actually doing the pattern matching in your project.  You can add more patterns also..

    Monday, February 22, 2010 12:04 AM
  • User360451555 posted

    hi guys.....thnks a lot.....it really worked perfectly well.....am soo happy.......but what will make me more happy is that i wouldn't like people to access the resources of my ~/StudentDetails.aspx page using the old URL......

    i want to show the new rewritten URL even when someone hovers on that link.....i want it to show

    ~/ERP/StudentDetails/107-063061-00055.aspx instead of ~/ERP/StudentDetails.aspx?RegNo=107-063061-00055

    So basically, i dnt want people to know the details of that link so even if they hover on it from another page, they get the rewritten URL shown and not the old one

    Monday, February 22, 2010 1:10 AM
  • User845932231 posted

    Great to know you got it working..

    Now you need to rework on all the pages where you showing URLs. You need to change all the old pattern urls to new urls.


    If you check the view source of Nestle site I send to you, you can see we are showing the rewrited urls, so that the user will never know what the orginal url working in the background..


    It may be a big task in an existing project, but you need to do it if you want the users use the friendly urls..

    Monday, February 22, 2010 2:45 AM
  • User360451555 posted

    Hey..thanks....i loved nestle-family website....it really looks soo juicy.....felt thirsty when i visited it.....

    Anyways.....i really thnk you guys for all the knowledge u are giving me...But i never undestood how to really implement wat i require...dnt knw if am using the wrong english to elaborate myself.

    I tried to browse my server with the New URL (Rewritten URL) and i got the page i requested and that was

    ~/ERP/StudentDetails/107-063061-00055.aspx. But when am going through my links and fall hover onto that link especially from a GridView, i get the Old URL displaying in the Status bar of my browser....when i click onto that link furthermore, i get the old URL and not the new URL in the Address Bar.

    So how can i ensure that all the links that Map to the Old URL are actually turned into the New URL....its true i dnt want the OLD URL to appear anywhere. How can i make the Old URL vanish completly and it will be known to only me.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 22, 2010 3:26 AM
  • User845932231 posted

    Yes I well undestood the question..

    What I am trying to tell is you need to change the menu links to the new pattern..

    if you have a menu with link like following

    <a runat="server" href="~/ERP/StudentDetails.aspx?RegNo=107-063061-00055">TEST</a>

    you need to change it like following

    <a runat="server" href="~/ERP/StudentDetails/107-063061-00055.aspx">TEST</a>

    If you are dynamically generating your menu links, you need to re-write the program to out put the links in the new pattern...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 23, 2010 5:06 AM
  • User360451555 posted

    Thanx man.....the stuff really worked for me....am so damn happy.....Long live ASP.NET....av marked as answered.....u really deserver those points

    Tuesday, February 23, 2010 1:05 PM