Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

Dynamic URL rewrite problem

$
0
0
Hi!

I've got a quite difficult question from which I havent managed to get any answers to in another swedish forum therefore I try to ask it here and I will be most thankful if you could help me out with this one, its currently stalling the project I'm working on atm.

The question is:

I've got this type of URL from a search on my website: search.aspx?section=html&q=css-beginners and I'm rewriting it to /articles/html/css-beginners with this rewriterule:

<rule name="section search" stopProcessing="true">
    <match url="^articles/([^/]+)/([^/]+)/?$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="search.aspx?section={R:1}&q={R:2}" appendQueryString="false" />
</rule>

However I've also got this option to filter down the search result depending on the creation date which is using this raw url search.aspx?q=css-beginners&sort=latest and I want it to be rewritten to /articles/css-beginners/latest. Note that the section should not be considered in this type of filtering. I've tried with this rule:

<rule name="Filter latest" stopProcessing="true">
    <match url="^articles/([^/]+)/latest/?$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="search.aspx?q={R:1}&sort=latest" appendQueryString="false" />
</rule>

But when I tries to go this url: /articles/css-beginners/latest which is search.aspx?q=css-beginners&sort=latest My latest rule isnt being considered and I'm rewritten to /articles.aspx?section=css-beginners&q=latest which is completly wrong.

Do you guys have any idea of how i should accomplish this? This is the first time I'm working with the URL rewrite module 2.0 but if I remember it right I could do like what I've tried here above in PHP and it would be taken care of as I want.
Does the rules have any sort of hierarchy, like CSS that the rules in the bottom automatically overrides the top ones, but in this case if may be the other way round?

If you could help me out with this I will be forever grateful
Thank you!

//Lucas Welander


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>