Funky
Funky

Reputation: 13608

Umbraco URLRewrite .aspx pages

I have set up some nice url rewriting in the urlrewriting.config file. These work great. However, I would like to redirect all pages with a .aspx extension to it's correct page.

For example:

If I type this url in:

vouchersresults.aspx?term=Home_and_Garden

I want it to redirect to this:

/vouchersresults/Home_and_Garden

Both Urls work fine, but I don't want the site to use .aspx at all.

I have tried this little piece of code in the URLrewriting.config, it works great apart from on a page I have created with a few query string values:

<add name="301RedirectDirUrls"
   redirectMode="Permanent"
   redirect="Application"
   ignoreCase="true"
   rewriteUrlParameter="IncludeQueryStringForRewrite"
   virtualUrl="^\/(?!(umbraco\/|data\/|install\/|usercontrols\/|umbraco_client\/))(.*)\.aspx"
   destinationUrl="$1/$2" />

when I click on a paging button on this page (/VouchersResults/Home_and_Garden/) fires a postback it changes the url to the ugly one:

/VouchersResults/?term=Home_and_Garden

Does anyone have any ideas what could be causing this?

Thanks

Upvotes: 2

Views: 2259

Answers (1)

Eric Herlitz
Eric Herlitz

Reputation: 26307

Removing the aspx is built into umbraco. Set umbracoUseDirectoryUrls to true

In web.config appsettings

<add key="umbracoUseDirectoryUrls" value="true" />

Regarding the Url rewriting, if I would do this in IIS with URL Rewrite I'd do this

^vouchersresults/([^/]+)?$

Upvotes: 2

Related Questions