Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How do I create a urlrewrite rule that transforms:
to
service-locations/states/WASHINGTON.aspx
I tried this:
[code]
<
add name="statepicker"virtualUrl="~/LocationPicker.aspx?state=(.*)"rewriteUrlParameter="ExcludeFromClientQueryString"destinationUrl="~/service-locations/states/$1.aspx"ignoreCase="true" />
[/code]
but it doesn't seem to be picked up (do I need to reset the app pool?)
Any suggestions welcome.
The Url Rewriting uses regular expressions so I think you need the ^ at the start of the Virtual URL ( ^ = carat?) which tells the regular expression to start the match from the start of the string
Here is an example from the UrlReqriting.config
<urlrewritingnet xmlns="http://www.urlrewriting.net/schemas/config/2006/07"> <rewrites> <add name="produktidrewrite" virtualUrl="^~/product/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/product.aspx?productid=$1" ignoreCase="true" /> </rewrites></urlrewritingnet>
I will have a look to see if i have a good example and get back to you.
Well, so far I haven't had any luck with this.
Is anyone using this with umbraco?
I'm gonna go for another solution: change the LocationPicker.aspx reference in my html code :-s
After doing some playing about with umbraco and the UrlRewriting, it doesn't look possible from a QueryString.
This must be to do with the path only being processed (not 100% sure on this but looks very likely).
So to summarise for you, it is possible to do it the other way round ie page to another page with a query string appended:
Courtesy of CWS: The sample below rewrites a url from "/product/someproductid.aspx" to "/product.aspx?productid=someproductid"
<add name="CWS_emaiAFriendID" virtualUrl="^~/email-a-friend/(.[0-9]*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/email-a-friend.aspx?nodeID=$1" ignoreCase="true" />
Documentation for UrlRewriting
http://www.urlrewriting.net/160/en/documentation.html
Got it, we needed to escape the question mark
Try this:
This example keeps the URL as is
<add name="MyExample" virtualUrl="^~/\?mytest=(.*)" rewriteUrlParameter="IncludeQueryStringForRewrite" destinationUrl="~/mypage/$1" ignoreCase="true" />
This example changes the URL to the new one
<add name="MyExample" redirect="Application" virtualUrl="^~/\?mytest=(.*)" rewriteUrlParameter="IncludeQueryStringForRewrite" destinationUrl="~/mypage/$1" ignoreCase="true" />
Fabulous!!!
That works exactly!
Great stuff, thanks for sorting this out... RegEx is great, but nitty gritty ;-)
Thank you!
Well, I was a bit too soon calling it all good ... :-(
I guess in my enthousiasm I clicked on the destination node from within the umbraco admin app ...
It still doesn't work
<add name="statepicker" redirect="Application" virtualUrl="^~/\?state=(.*)" rewriteUrlParameter="IncludeQueryStringForRewrite" destinationUrl="~/service-locations/states/$1" ignoreCase="true" />
I try to tinker with it a bit myself ... RegEx doesn't seem to want to enter my brain atm :(
[code] <add name="statepicker" redirect="Application" virtualUrl="^~/LocationPicker.aspx\?state=(.*)" rewriteUrlParameter="IncludeQueryStringForRewrite" destinationUrl="~/service-locations/states/$1.aspx" ignoreCase="true" />[/code]
WORKS!!!
Thanks for getting me on track!!
No worries, I am glad that worked :)
Shout up if you have any further problems.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
url rewrite: somepage.aspx?var=VALUE --> somefolder/value.aspx
How do I create a urlrewrite rule that transforms:
LocationPicker.aspx?state=WASHINGTON
to
service-locations/states/WASHINGTON.aspx
I tried this:
[code]
<
add name="statepicker"
virtualUrl="~/LocationPicker.aspx?state=(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/service-locations/states/$1.aspx"
ignoreCase="true" />
[/code]
but it doesn't seem to be picked up (do I need to reset the app pool?)
Any suggestions welcome.
The Url Rewriting uses regular expressions so I think you need the ^ at the start of the Virtual URL ( ^ = carat?) which tells the regular expression to start the match from the start of the string
Here is an example from the UrlReqriting.config
I will have a look to see if i have a good example and get back to you.
Well, so far I haven't had any luck with this.
Is anyone using this with umbraco?
I'm gonna go for another solution: change the LocationPicker.aspx reference in my html code :-s
After doing some playing about with umbraco and the UrlRewriting, it doesn't look possible from a QueryString.
This must be to do with the path only being processed (not 100% sure on this but looks very likely).
So to summarise for you, it is possible to do it the other way round ie page to another page with a query string appended:
Courtesy of CWS: The sample below rewrites a url from "/product/someproductid.aspx" to "/product.aspx?productid=someproductid"
Documentation for UrlRewriting
http://www.urlrewriting.net/160/en/documentation.html
Got it, we needed to escape the question mark
Try this:
This example keeps the URL as is
This example changes the URL to the new one
Fabulous!!!
That works exactly!
Great stuff, thanks for sorting this out... RegEx is great, but nitty gritty ;-)
Thank you!
Well, I was a bit too soon calling it all good ... :-(
I guess in my enthousiasm I clicked on the destination node from within the umbraco admin app ...
It still doesn't work
Page not found
No umbraco document matches the url 'http://local.cms.development:90/LocationPicker.aspx?state=WASHINGTON'
[code]
<add name="statepicker"
redirect="Application"
virtualUrl="^~/\?state=(.*)"
rewriteUrlParameter="IncludeQueryStringForRewrite"
destinationUrl="~/service-locations/states/$1"
ignoreCase="true" />
[/code]
I try to tinker with it a bit myself ... RegEx doesn't seem to want to enter my brain atm :(
[code] <add name="statepicker"
redirect="Application"
virtualUrl="^~/LocationPicker.aspx\?state=(.*)"
rewriteUrlParameter="IncludeQueryStringForRewrite"
destinationUrl="~/service-locations/states/$1.aspx"
ignoreCase="true" />[/code]
WORKS!!!
Thanks for getting me on track!!
No worries, I am glad that worked :)
Shout up if you have any further problems.
is working on a reply...