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

Forums / General Discussions / URL Rewrite of group page gives 404

URL Rewrite of group page gives 404

7 posts, 0 answered
  1. Corby
    Corby avatar
    48 posts
    Registered:
    19 Sep 2011
    20 Jun 2013
    Link to this post
    I am trying to do a simple URL rewrite to remove the group folder containing pages from appearing in the URL and keep getting a 404 error message. Example:

    mysite.com/cats/cute-ones

    When someone lands on mysite.com/cats/cute-ones, I want to remove the /cats/ group folder from appearing in the URL.  My rule looks like this:

        <rewrite>
          <rules>
            <rule name="cats" stopProcessing="true">
              <match url="^cats/(.*)" />
              <action type="Rewrite" url="/{R:1}" />
            </rule>
          </rules>
        </rewrite>

    Interestingly, when I try to go into any page that is within the /cats/ group folder in Sitefinity's "Pages" view, I also get a 404.

    Can anyone help please?  I have looked at the forums and have Googled it, but nothing I have tried seems to work.  I'm missing something....thanks in advance to all who take the time to review this post.

    Note (Sitefinity 6 VS 2012, 4.5 .NET framework, hosted on Azure)
  2. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    20 Jun 2013 in reply to Corby
    Link to this post
    Corby,

    I believe adding the rewrite rules might be breaking the Sitefinity rules for rewriting.  You should check out with the titles & properties of the page Allow Multiple URLs.  Here you could set the page to be just ~/cute-ones
  3. Corby
    Corby avatar
    48 posts
    Registered:
    19 Sep 2011
    20 Jun 2013 in reply to Jonathan
    Link to this post
    The only issue I have with that is the number of pages in the /cats folder.  If I am able to do one single rewrite rule in the web.config, I won't have to edit X # of pages manually in the Titles and Properties settings as you have suggested.  Thank you for replying, though.  I appreciate it.
  4. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    20 Jun 2013 in reply to Corby
    Link to this post
    Is there any type of pattern that the sub items can match?
    The problem with your rule is that it is rewriting the URL to /cute-ones well sitefinity doesnt have a file/document at /cute-ones

    this rule works for what you want but the problem is that it will take /anything and rewrite it to /cats/anything

    <rules>
      <rule name="cats" stopProcessing="true">
          <match url="^cats/(.*)" />
          <action type="Rewrite" url="/{R:1}" />
      </rule>
    </rules>

    So if there is some type of pattern that the sub page cans match i think you can create a rule that would work.

    Here is the IIS Documentation
    Creating Rules
    Config Reference
  5. Corby
    Corby avatar
    48 posts
    Registered:
    19 Sep 2011
    20 Jun 2013 in reply to Jonathan
    Link to this post
    I just want to remove the /cats/ sub-folder from appearing in the url, taking anything behind it and appending it to mysite.com/

    mysite.com/cats/about-us
    mysite.com/about-us

    mysite.com/cats/cute-ones/big/white
    mysites.com/cute-ones/big/white

    Isn't the URL Rewriting only supposed to change the URL that appears in the address bar so even though you are going to 

    mysite.com/cats/cute-ones/big/white
    the end user sees
    mysites.com/cute-ones/big/white
    ?


  6. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    20 Jun 2013 in reply to Corby
    Link to this post
    The original intention for url rewriting is for Query strings.  So example
    /product?type=shoes&color=red&style=running
    The isnt very readable so the user would instead navigate to /product/shoes/running/red this would show up to the server as the above querystring the product page only knows how to read the query parameters to show content so the pages itself still sees the querystring but the user see the "pretty" string.  But this only works because there is a clearly define pattern to match.
  7. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    25 Jun 2013
    Link to this post
    Hello,

    Thank you Jonathan for sharing this information and for helping Corby resolve his problem.

    Regards,
    Stefani Tacheva
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
7 posts, 0 answered