Just wondering what the best way to do SO style routes is.
What's the best way to create routes like this?
Just wondering what the best way to do SO style routes is.
What's the best way to create routes like this?
I think the best way would be to replace any non-alphanumeric character with a dash. You could search for this regex [^\w]+
and replace with -
.
I've found ASP.NET MVC and Clean SEO Friendly URLs on Dominic Pettifer's blog.
It works on a white-list principle, allowing all 0-9 and a-z characters through, dealing with a few special cases, and converting everything else to -hyphens-. You'll notice that spaces are being converted to hyphens as well, and you might be tempted to use underscores instead. Don't! There are sound SEO benefits for using hyphens in that search engines bots treat them as spaces.