There's a commented-out rule in the default /config/UrlRewriting.config file that details almost exacly what you want to do:
The sample below rewrites a url from "/product/someproductid.aspx" to "/product.aspx?productid=someproductid" The user will not see the rewritten path! The page that will be loaded from umbraco will instead be:"/product.aspx?productid=someproductid" <add name="produktidrewrite" virtualUrl="^~/product/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/product.aspx?productid=$1" ignoreCase="true" />
The URL would under normal surcomstanses be /product.aspx?id=someproductid
I would like it to "do the same thing" but the url representet to the user is /product/someproductid
@Kaster: use the above solution.. it will work for what you want.
In your site when directing the user..use something like /product/1234.aspx and urlrewriting will take care of direct the server to /product.aspx?productid=1234
Users will always see /product/1234.aspx
You will be able to access querystrings in your code as Request.QueryString["id"]
Your confusion is not uncommon... urlrewriting does not rewrite to the client, but rewrites to the server.
Make querystring look like url path
Hi,
This may a crazy question, but here it is... How can I make the query string appears as a part of the url path?
Let me show... I would like this:
look like this:
or:
...without any redirects or anything like that.
I have found this http://stackoverflow.com/questions/4630720/converting-wordpress-url-path-into-query-string that also describes it. But here I need to work with Umbraco/C#.
Any ideas?
Hi Kasper,
Why not use url rewriting rules ?
There's a commented-out rule in the default /config/UrlRewriting.config file that details almost exacly what you want to do:
HTH,
Hendy
It's a nice feature, but I would like something that does the opposite...
From /product.aspx?id=someproductid to /product/someproductid.aspx
Hi Kasper,
I'm not sure I understand your requirements, which URL do you want visible in the address bar ?
Cheers,
Hendy
The URL would under normal surcomstanses be /product.aspx?id=someproductid
I would like it to "do the same thing" but the url representet to the user is /product/someproductid
Hendy's solution is correct.
@Kaster: use the above solution.. it will work for what you want.
In your site when directing the user..use something like /product/1234.aspx and urlrewriting will take care of direct the server to /product.aspx?productid=1234
Users will always see /product/1234.aspx
You will be able to access querystrings in your code as Request.QueryString["id"]
Your confusion is not uncommon... urlrewriting does not rewrite to the client, but rewrites to the server.
Can anyone validate me on this?
Hi Daniel
Your explanation make sense to me. :o)
Now I just have to try it. I'll let you know how it turns out.
is working on a reply...