Quantcast
Channel: URL Rewrite Module
Viewing all articles
Browse latest Browse all 2482

Two Question Marks in an Unknown URL

$
0
0

Hi there,

I have a CMS system that people place articles into.  It's third party and I have no control over the content they place in there or access to alter the source.  But I can configure the rewrite rules.

Sometimes an author will put a question mark in a title and that title is passed into the url that is used to refer to an article. This is an example: -

http://www.pfc.com/News/Leopold-to-bring-$9,000?/13857.page?catid=26

I have no idea beforehand what they URLs will be.

My question is how do I remove them so that the URL will look like the following?

http://www.pfc.com/News/Leopold-to-bring-$9,000/13857.page?catid=26

This is the correct URL for this article.

Essentially I want to remove any question marks in the page section of the URL, but because it's a question mark it's not clear if the URL is being split in the correct place. Does the QUERY_STRING or the REQUEST_URI contains the extra question mark?  How can I formulate a rule that both catches these and also correctly rewrites them, removing the first question mark(s).

These are some rules I've tried: -

<rule name="Clean extra question mark from request uri-1 if the ? is at the end" stopProcessing="false">
    <match url="(.*)\?$" />
<action type="Rewrite" url="{R:1}" appendQueryString="true" />
</rule>


<rule name="Clean extra question mark from query string-1" stopProcessing="false">
    <match url="(.*)" />
    <conditions>
        <add input="{REQUEST_URI}" pattern="([^\?]*)\?([^\?]*)" />
    </conditions>
    <action type="Rewrite" url="{R:1}/{C:1}{C:2}" appendQueryString="true" />
    <!-- also tried: action type="Rewrite" url="(UrlEncode:{REQUEST_URI}}" appendQueryString="true" / -->
</rule>



Viewing all articles
Browse latest Browse all 2482

Trending Articles



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