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
Hey,
I would appreciate all the help you guys could give me.
I'm trying to rewrite all urls where specific querystring is added to f.ex
http://Site.com/X/X?queryString=123 -> http://Site.com/X/X/123
http://Site.com/X?queryString=123 -> http://Site.com/X/123
http://Site.com/X/X/X?queryString=123 -> http://Site.com/X/X/X/123
And so on...
This querystring can be on any level on the page and i want to be able to link to page with the friendly url parth like : http://Site.com/X/X/X/123 or link with http://Site.com/X/X/X/?queryString=123 so long as is it will be rewritten.
I'm trying to use the http://www.urlrewriting.net/ included in the Umbraco but I can use MVC routing to.
Any thoughts on the issue would be really helpful !
Hi Garðar,
I'd try using a UrlRewriting rule like this:
<urlrewritingnet xmlns="http://www.urlrewriting.net/schemas/config/2006/07"> <rewrites> <add name="category-listing" virtualUrl="~/(.*)/?queryString=(.*)" destinationUrl="~/$1/$2" rewriteUrlParameter="ExcludeFromClientQueryString" ignoreCase="true" /> </rewrites> </urlrewritingnet>
Hope this helps?
Cheers, - Lee
Thank you Lee for the quick response.
I did try your rewrite but does not seem to work.
When I try http://Site.com/X/?queryString=123 nothing is rewritten, if I try http://Site.com/X/123 the page is not found.
Do you have any other ideas ? :)
Does "http://Site.com/X/?queryString=123" work as intended? As in the page functions as you want it? (just checking)
Not sure why the UrlRewriting didn't work though. Maybe look at using IIS's/.NET's built-in rewriting module? I don't have an example to hand, but more info here: http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
Yes the path with the querystring is working as intended.
When I try to hardcode the path it works like :
<add name="rewrite"
virtualUrl="^~/A/B/(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/A/B/?queryString=$1"
ignoreCase="true" />
This works too but it will ofcourse conflict with to many pages :)
virtualUrl="^~/(.*)/(.*)/(.*)"
destinationUrl="~/$1/$2/?queryString=$3"
Does this info help ?
Ah, yes - I misunderstood, I thought you wanted to rewrite from the querystring to the URL without it.
You could try something like this?
<add name="rewrite" virtualUrl="~/(.*)/([\d]*)" destinationUrl="~/$1/?queryString=$2" rewriteUrlParameter="IncludeQueryStringForRewrite" redirectMode="Permanent" ignoreCase="true" />
Wow thanks Lee !
This rewrite did the job, but one thing that it seems to conflict with is my custom MVC section inside Umbraco.
Can I make this rule only work inside the page and not affect anything in the Umbraco ?
I'm not using this specific querystring inside the MVC routing if that helps.
Hmmm... maybe by adding "/umbraco" into the RegEx for the match?
virtualUrl="~/(.*|!^umbraco)/([\d]*)"
... but I'm no RegEx master, so it probably needs tweaking :-)
Ahh I found out that this is not really conflicting with Umbraco, the section is inside App_Plugins folder and there it conflicts.
So I would need to exclude the rule from this path, your last edit did not seem to get the job done so I'm reading upon regex at the moment :)
Thank you really mutch for this help ! saved me alot of time !
If you do find out how to exclude a path it would be appreciated :)
Any thoughts on the matter ? :)
Only thought is to hack around with the RegEx to exclude the folder/path that conflicts.
Here is the solutions I'm using at the moment.
I use Url rewrite module in the IIS
This will change :
/archive/article/2013/11/18/Alias to /archive/article?id=Alias
<rewrite>
<rules>
<rule name="uArticles" stopProcessing="true">
<match url="^(?!(app_plugins|umbraco))(.*)/[0-9]+/[0-9]+/[0-9]+/([_0-9a-z-]+)$" />
<action type="Rewrite" url="{R:2}/?Id={R:3}" />
</rule>
</rules>
</rewrite>
Well, you can use Long Path Tool for such problems, I will say.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Url rewrite condition, rewrite all paths where querystring is added
Hey,
I would appreciate all the help you guys could give me.
I'm trying to rewrite all urls where specific querystring is added to f.ex
http://Site.com/X/X?queryString=123 -> http://Site.com/X/X/123
http://Site.com/X?queryString=123 -> http://Site.com/X/123
http://Site.com/X/X/X?queryString=123 -> http://Site.com/X/X/X/123
And so on...
This querystring can be on any level on the page and i want to be able to link to page with the friendly url parth like : http://Site.com/X/X/X/123 or link with http://Site.com/X/X/X/?queryString=123 so long as is it will be rewritten.
I'm trying to use the http://www.urlrewriting.net/ included in the Umbraco but I can use MVC routing to.
Any thoughts on the issue would be really helpful !
Hi Garðar,
I'd try using a UrlRewriting rule like this:
Hope this helps?
Cheers,
- Lee
Thank you Lee for the quick response.
I did try your rewrite but does not seem to work.
When I try http://Site.com/X/?queryString=123 nothing is rewritten, if I try http://Site.com/X/123 the page is not found.
Do you have any other ideas ? :)
Does "http://Site.com/X/?queryString=123" work as intended? As in the page functions as you want it? (just checking)
Not sure why the UrlRewriting didn't work though. Maybe look at using IIS's/.NET's built-in rewriting module?
I don't have an example to hand, but more info here: http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
Yes the path with the querystring is working as intended.
When I try to hardcode the path it works like :
<add name="rewrite"
virtualUrl="^~/A/B/(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/A/B/?queryString=$1"
ignoreCase="true" />
This works too but it will ofcourse conflict with to many pages :)
<add name="rewrite"
virtualUrl="^~/(.*)/(.*)/(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/$1/$2/?queryString=$3"
ignoreCase="true" />
Does this info help ?
Ah, yes - I misunderstood, I thought you wanted to rewrite from the querystring to the URL without it.
You could try something like this?
Cheers,
- Lee
Wow thanks Lee !
This rewrite did the job, but one thing that it seems to conflict with is my custom MVC section inside Umbraco.
Can I make this rule only work inside the page and not affect anything in the Umbraco ?
I'm not using this specific querystring inside the MVC routing if that helps.
Hmmm... maybe by adding "/umbraco" into the RegEx for the match?
... but I'm no RegEx master, so it probably needs tweaking :-)
Ahh I found out that this is not really conflicting with Umbraco, the section is inside App_Plugins folder and there it conflicts.
So I would need to exclude the rule from this path, your last edit did not seem to get the job done so I'm reading upon regex at the moment :)
Thank you really mutch for this help ! saved me alot of time !
If you do find out how to exclude a path it would be appreciated :)
Any thoughts on the matter ? :)
Only thought is to hack around with the RegEx to exclude the folder/path that conflicts.
Here is the solutions I'm using at the moment.
I use Url rewrite module in the IIS
This will change :
/archive/article/2013/11/18/Alias to /archive/article?id=Alias
<rewrite>
<rules>
<rule name="uArticles" stopProcessing="true">
<match url="^(?!(app_plugins|umbraco))(.*)/[0-9]+/[0-9]+/[0-9]+/([_0-9a-z-]+)$" />
<action type="Rewrite" url="{R:2}/?Id={R:3}" />
</rule>
</rules>
</rewrite>
Well, you can use Long Path Tool for such problems, I will say.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.