Possible Duplicate:
How does StackOverflow generate its SEO-friendly URLs?
I have an MVC3 site for which I would like to clean up the urls that contain spaces in the names of the products.
Currently, the url displays as: /products/some%20ugly%20url
I would like to display: /products/some-clean-url
Is it possible with MVC3 routing to rewrite the ugly url to the clean one?
-
Can't you just rename your files with - instead of spaces?Rob– Rob2012年10月29日 12:55:57 +00:00Commented Oct 29, 2012 at 12:55
-
Unfortunately no because it relies on another service that requires the spaces. I suppose I could do the rewrite before the service call though instead.shuniar– shuniar2012年10月29日 13:10:46 +00:00Commented Oct 29, 2012 at 13:10
1 Answer 1
Short answer: yes this is possible. Just look up. StackExchange runs on ASP.NET MVC.
Try creating a product slug. A slug is a unique string that identifies your item that you want to fetch.
/products/fake-blood
/products/spiders-webs
/products/vampire-teeth
You can then key off the slug, instead of an ID. Many solutions store the slug in the database.
1 Comment
Explore related questions
See similar questions with these tags.