URL Rewrite of group page gives 404

Posted by Community Admin on 03-Aug-2018 12:20

URL Rewrite of group page gives 404

All Replies

Posted by Community Admin on 20-Jun-2013 00:00

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)

Posted by Community Admin on 20-Jun-2013 00:00

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

Posted by Community Admin on 20-Jun-2013 00:00

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.

Posted by Community Admin on 20-Jun-2013 00:00

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

Posted by Community Admin on 20-Jun-2013 00:00

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
?


Posted by Community Admin on 20-Jun-2013 00:00

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.

Posted by Community Admin on 25-Jun-2013 00:00

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

This thread is closed