I am using IIS 8.0 and Umbraco 7. I am trying to make a url like this: testdomain.com/somecategory?page=2 look like testdomain.com/somecategory/page/2. I created a rewrite rule but it doesn't work I always get a HTTP Error 500.52 - URL Rewrite Module Error.
<rule name="pageNationRule" stopProcessing="true">
<match url="(.+)/(page)/(\d+)(|/)$"/>
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}?{R:2}={R:3}"/>
</rule>
Any help would be appreciated.
Thanks in advance,
You will have to setup these rules in UrlRewrite.config in /config folder in your umbraco websites root. To add new rule:
<add name="produktidrewrite"
virtualUrl="^~/product/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/product.aspx?productid=$1"
ignoreCase="true" />
Or you can add a custom route in your code. Create a new class which inherit from from Umbraco.Core.ApplicationEventHandler Overwrite ApplicationStarted to add your rules. Like this:
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
//Custom route
RouteTable.Routes.MapRoute(
"SomeName",
"Something/{action}/{id}",
new
{
controller = "ControllerName",
action = "Index",
id = UrlParameter.Optional
});
}
The error was probably because you had an extra / in the opening match tag. D'oh.
However, to simplify the rule you should be able to use:
<rule name="pageNationRule" stopProcessing="true">
<match url="(.+)/page/(\d+)/?$" ignoreCase="true">
<action type="Rewrite" url="{R:1}?page={R:2}"/>
</rule>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.