UrlRewritingNet, redirecting foo/bar.aspx to foo/bar/
Hi,
I've got a scenario there i want the site to run with umbracoUseDirectoryUrls set to true and redirect all calls to "foo/bar.aspx" to the directory "/foo/bar/".
I thought i might be able to do it with UrlRewritingNet, setting a rewrite like:
That will, of course, also redriect all calls to "/umbraco/foo.aspx" to "/umbraco/foo/".
I've tried all kinds of black magic (reads regular expressions) to exclude "/umbraco/", without success. I cant seem to find the correct expression.
Also, i've tried to add the attribute rewriteOnlyVirtualUrls to the urlrewritingnet element, setting it to false, but for some reason "/umbraco" seems to be treated as a virtual url, or the parameter just doesnt work.
<!-- SEO | Trim .aspx for directory URLs --> <!-- Note: using UrlRewriting.Net because IIS UrlRewriting doesn't like rules with .aspx in it --> <add name="SEO | Trim .aspx for directory URLs" redirect="Application" redirectMode="Permanent" virtualUrl="^/(?![0-9]+.aspx)(?!umbraco/)([^\?]*?).aspx$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="/$1" ignoreCase="true" />
UrlRewritingNet, redirecting foo/bar.aspx to foo/bar/
Hi,
I've got a scenario there i want the site to run with umbracoUseDirectoryUrls set to true and redirect all calls to "foo/bar.aspx" to the directory "/foo/bar/".
I thought i might be able to do it with UrlRewritingNet, setting a rewrite like:
<add name="aspxToFolder" virtualUrl="(.*).aspx" destinationUrl="~$1/" redirectMode="Permanent" ignoreCase="true" redirect="Application" />
That will, of course, also redriect all calls to "/umbraco/foo.aspx" to "/umbraco/foo/".
I've tried all kinds of black magic (reads regular expressions) to exclude "/umbraco/", without success. I cant seem to find the correct expression.
Also, i've tried to add the attribute rewriteOnlyVirtualUrls to the urlrewritingnet element, setting it to false, but for some reason "/umbraco" seems to be treated as a virtual url, or the parameter just doesnt work.
How do i make the redirect work?
Thank you!
Minor edit: destinationUrl="/$1" should in my case have a tailing slash, destinationUrl="/$1/" (for future reference).
Excellent, thank you!
Aight, I'll edit mine too :-) Ty
is working on a reply...