+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / URL Rewrite problem

URL Rewrite problem

12 posts, 1 answered
  1. Nimit
    Nimit avatar
    90 posts
    Registered:
    27 Mar 2009
    11 Nov 2010
    Link to this post
    Hi there,
    I created a job module and a user control that displays job when certain category is select and there is guid in the url. Now client does not want a guid instead he wants a text name. I thought of doing url rewrite, but my problem is it doesn't work. Here is the example:-->

    http://localhost/joblistings.aspx?CatName=Information_Technology&JobID=16021284-82f6-43d2-ab4e-0c79052a631d&JobName=Network_Security_Specialist 

    I want it be be showed as
    http://localhost/joblistings.aspx/Information_Technology/Network_Security_Specialist.aspx 

    I did all the steps like
    1. Add a configuration section element <configSections>:

    <section name="urlrewrites"

    type="Telerik.Cms.Web.AdvancedUrlRewriter, Telerik.Cms"/>

    2.  In the <httpModules> section, replace the default CmsHttpModule with
    CmsHttpModuleUrlRewrite
    3. Set up your rules. Add an <urlrewrites> section and creating rules
    and here is my rule:
     <rule>
           <url>joblistings\.aspx?CatName=(\s+)&amp;JobID=(\s+)&amp;JobName=(\s+)</url>
           <rewrite>joblistings/$1/$3.aspx</rewrite>
       </rule>

    Now the issue is that it's not working at all I mean nothing is happening. Can you please guide on what i am doing wrong.

    Regards,
    Nimit Verma
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Nov 2010
    Link to this post
    Hello Nimit,

    To register the module for IIS 6.0 and IIS 7.0 running in Classic mode you should use the web.config sections below

    <configuration>
      <system.web>
        <httpModules>

    To register the HTTP Module in IIS 7.0 Integrated Mode you should use the web.config sections below

    <configuration>
      <system.webServer>
        <modules>

    Instead of using the rewriting you can easily resolve the ID to "name" in the code where you pass it as a QueryString.


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Nimit
    Nimit avatar
    90 posts
    Registered:
    27 Mar 2009
    11 Nov 2010
    Link to this post
    Hi Ivan,
    Thank you for the quick reply.
    I tried the changes you told me, but it didn't work
    I want it behave like news view control.
    So that the querystring url which is like :-->

    http://localhost/joblistings.aspx?CatName=Information_Technology&JobID=16021284-82f6-43d2-ab4e-0c79052a631d&JobName=Network_Security_Specialist 

    will looks like :-->
    http://localhost/joblistings.aspx/Information_Technology/Network_Security_Specialist.aspx/joblistings.aspx/Information_Technology/Network_Security_Specialist.aspx

    Please reply ASAP.

    Regards,
    Nimit Verma
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Nov 2010
    Link to this post
    Hello Nimit,

    1. Make sure that the module has been correctly set up. You can try with a very simple rule

    2. Your rule is completely wrong. Here is the correct one that will validate the url you pasted

    joblistings\.aspx\?CatName=([a-zA-z]+)&JobID=(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}&JobName=([a-zA-z]+)

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Nimit
    Nimit avatar
    90 posts
    Registered:
    27 Mar 2009
    17 Nov 2010
    Link to this post
    Hi Ivan,
    Thank you for you reply.
    I tried the url regex you gave me and it did work a bit, but I don't know why it's giving me the server error and not simply replacing the explorer url.

    The url is :--> http://localhost/joblistings.aspx?CatName=Information_Technology&JobID=72ccbf6b-f29c-47b1-b54a-94696fea93ed&JobName=Web_Applications_Developer

    I want to replace it with:--> http://localhost/joblistings/Information_Technology/Web_Applications_Developer.aspx

    The error is as follows:-->
     

    Server Error in '/' Application.

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /joblistings/Information_Technology/Web_Applications_Developer.aspx


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1


    Please reply and suggest me what should I do,

    Regards,
    Nimit Verma.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Nov 2010
    Link to this post
    Hi Nimit,

    Most probably the JobName is not valid or this rule does not cover all possible comibnations that you might have.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Nimit
    Nimit avatar
    90 posts
    Registered:
    27 Mar 2009
    17 Nov 2010
    Link to this post
    Hi Ivan,
    Thanks for the quick reply.
    Two things:-->

    1. I think the rule is working because the server error shows
    "Requested URL: /joblistings/Information_Technology/Web_Applications_Developer.aspx" (which is the url I wanted)
    replacing joblistings.aspx?CatName=Information_Technology&JobID=16021284-82f6-43d2-ab4e-0c79052a631d&JobName=Network_Security_Specialist 

    2. Can you please explain what do you mean by "JobName is not valid", if possible.

    Please suggest.
    Thank you,
    Nimit Verma.
  8. Nimit
    Nimit avatar
    90 posts
    Registered:
    27 Mar 2009
    20 Dec 2010
    Link to this post
    Hi Ivan,
    Can you please guide on couple of things:-->

    1. Can you please explain what do you mean by "JobName is not valid", if possible.

    2. I think the rule is working because the server error shows
    "Requested URL: /joblistings/Information_Technology/Web_Applications_Developer.aspx" (which is the desired url)
    replacing joblistings.aspx?CatName=Information_Technology&JobID=16021284-82f6-43d2-ab4e-0c79052a631d&JobName=Network_Security_Specialist 

    Please suggest ASAP.
    Thank you,
    Nimit Verma.
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Dec 2010
    Link to this post
    Hi Nimit,

    The problem is that you are passing not valid parameters to the query string or/and you are not replacing the urls properly. Please check the parameters you use and the rewrite rules you have.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Nimit
    Nimit avatar
    90 posts
    Registered:
    27 Mar 2009
    21 Dec 2010
    Link to this post
    Hi Ivan,
    Thank you for your response.
    If possible, can you please guide me about how the URL rewrite works.
    Even if I write a URL rewrite rule for a specific web page it gives error that "Resource cannot be found".

    When we create a rule for the existing URL does the desired URL need to exist.

    Please reply soon.

    Regards,
    Nimit Verma.
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Dec 2010
    Link to this post
    Hello Nimit,

    Here is a short post that explains how the rewriter works. Here you will find sample project and code snippets.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  12. Nimit
    Nimit avatar
    90 posts
    Registered:
    27 Mar 2009
    28 Dec 2010
    Link to this post
    Hi,
    thank you for the reply.
    I looked into the links you gave.
    one of the link http://www.sitefinity.com/devnet/forums/sitefinity-3-x/general-discussions/rewrite.aspx says that the rewrite url should already exist.

    but In my senario the rewrite url doesn't exist,
    now I will give you a simple example which I did:-->

    take a url
    http://localhost/aboutus.aspx

    I want the above url should look like :-->
    http://localhost/about_us.aspx (only the aboutus.aspx should show about_us.aspx).

    The rule I created is as follows:
    <urlrewrites>
    <rule>
    <
    url>aboutus\.aspx</url>
    <
    rewrite>about_us.aspx</rewrite>
    </
    rule>
    </
    urlrewrites

    Then when I click on the about us page, it gives error that HTTP 404, resource not found.
    requested URL: /ourcompany/about_us.aspx

    Please reply and suggest me.

    Regards,
    Nimit Verma.

     

     

     


     

Register for webinar
12 posts, 1 answered