Reputation: 73
I use url rewrite. I add some rule like that:
<add name="Homes" virtualUrl="^/(.*).html" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="/Default.aspx?vsm=$1" ignoreCase="true" />
<add name="HomeNew" virtualUrl="^/(.*)/(.*)/" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="/Default.aspx?vsm=$1&idcnew=$2" ignoreCase="true" />
<add name="HomeNewPage" virtualUrl="^/(.*)/(.*)/page-([0-9-]*).htm" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="/Default.aspx?vsm=$1&idcnew=$2&page=$3" ignoreCase="true" />
<add name="HomeNewNew" virtualUrl="^/(.*)/(.*)/(.*)-([0-9-]*).htm" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="/Default.aspx?vsm=$1&idcnew=$2&idnew=$4" ignoreCase="true" />
I have to use all of them. In HomeNewPage rule, I use to get catalog new page. In HomeNewNew rule, I use to get content new with $3 is url name of new. But when go to this link: "/News/Alert/page-2" my request is "vsm=News&idcnew=Alertpage-2" I want my request is "vsm=News&idcnew=Alert&page=2" Please help me! What's wrong? And how to fix it?
Upvotes: 0
Views: 84
Reputation: 354
According to me your Regex expression:
/([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*)/page-([0-9-]*)\.htm
will work. But this expression
/([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*)/"
wont work as it does consist of arguement for third tag(page-2). But this will work till /News/Alert. Please check your code or try to debug it according to me there is some hardcoding done. Due to which you're getting error.
I'll give you a very easy way to detect your expressions. After this you'll be able to validate your expressions appropriately.
Go to this link : http://www.rexfiddle.net/
And insert your expression and in second window insert the url you want. After this you'll get captures in the end linke capture 1, capture 2, capture 3. These will be come out to be your arguements($1, $2......). See the screenshot below:
Upvotes: 0
Reputation: 354
If the url is like
"/Default/News/Alert/page-2.html"
Regex:- /(.*)/(.*)/(.*)/page-(.*).html
"/Default/News/Alert/page-2"
Regex:- /(.*)/(.*)/(.*)/page-(.*)
and you can make the new url as /Default.aspx?vsm=$2&idcnew=$3&page=$4
Basically each (.*) specify the argument like
If we take your second expression ^/(.*)/(.*)/. In this case it may creates the problem with url like News/Alert/page-2 because it doesn't "/" in the end. Same is the reason with .html. As you've not provided the url so I'm not sure about ^. But this will come only if your url will fulfill the regex from first character, however, it wont leads to any problem. You can specify or remove it.
Upvotes: 1