The "name" attribute should ideally not contain spaces;
The "virtualUrl" attribute should begin with a caret ^ (to anchor the regex to the start of the URL), followed by tilde ~ (to handle the virtual path of the request), and end with dollar $ (to mark the end of the string);
The "destinationUrl" attribute should begin with a tilde ~ to handle the virtual path of the URL to rewrite to.
Thank you for your help. After the changes, I got "mysite.com/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/mobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspx"
And got en error. As you can see, it repeats the destination url...
Again, from my limited knowledge of the subject (and a quick inspection of the documentation) you only need redirect="domain" if you are redirecting to another domain, in which case you'd have to include the full path in the destinationUrl i.e destinationUrl="http://www.newdomain.com/a-propos/mobile.aspx" /> taking this out means its just doing a normal rewrite rather than a redirect. you could also specify redirect="Application" which I suspect would work as well.
Url rewriting
Hi,
I must use urlrewriting in Umbraco because I don't have acces to IIS.
So, I'm only try to redirect mysite.com/m or www.mysite.com/m to www.mysite.com/someurl.aspx
My regex skills are near 0, so here's my code that does not work :
<add name="redirect mobile"
redirect="Domain"
ignoreCase="true"
rewriteUrlParameter="IncludeQueryStringForRewrite"
redirectMode="Permanent"
virtualUrl="/m"
destinationUrl="/a-propos/mobile.aspx" />
Hi Profiterole,
Try this:
Three main differences:
Try this and let us know how you get on.
HTH,
Benjamin
Hi Benjamin,
Thank you for your help. After the changes, I got "mysite.com/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/a-propos/mobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspxobile.aspx"
And got en error. As you can see, it repeats the destination url...
Ok, still not answered. I'm not using extensionless site, so is it possible that the server does not know what to do with /m whitout extension?
Hi Profiterole, try taking the redirect="domain" out of the equation and it should work.
you should be left with something like:
<add name="RedirectMobile"
redirectMode="Permanent"
ignoreCase="true"
rewriteUrlParameter="IncludeQueryStringForRewrite"
virtualUrl="^~/m$"
destinationUrl="~/a-propos/mobile.aspx" />
I'm certainly no regex guru either, but the above should work.
- Tim
Hi Tim, I don't know why I should take off the redirect="domain", but it worked! Thank you!
Again, from my limited knowledge of the subject (and a quick inspection of the documentation)
you only need redirect="domain" if you are redirecting to another domain, in which case you'd have to include the full path in the destinationUrl i.e destinationUrl="http://www.newdomain.com/a-propos/mobile.aspx" />
taking this out means its just doing a normal rewrite rather than a redirect.
you could also specify redirect="Application" which I suspect would work as well.
check out the documentation:
http://www.urlrewriting.net/160/en/documentation/documentation/documentation/documentation/documentation/documentation.html it seems to be reasonably comprehensive and is well worth knowing if you're going to be working with redirects a lot.
anyway, glad you got it working,
- Tim
is working on a reply...