Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do get clean URLs like Stack Overflow?

Tags:

On some .NET driven sites URLs don't end with asp.net page names, like default.aspx, instead they use a pattern http://sitename.com or http://sitename.com/subdirectory/subdirectory. The site is mapped as sub directories off the root, ie. /tags, /users, /badges, the URLs would be /tags, /users, /badges respectively.

Stack Overflow, to use a specific example, uses question URLs of the form How do get clean URLs like Stackoverflow?. Which is great way to optimize the page for search engines.

Is this implemented using HTTP handlers? Is the GET request filtered based on path and the whole response is formed in the handler itself based on the question id? Anyone else care to speculate?

like image 631
Shankar Avatar asked Jun 23 '09 21:06

Shankar


People also ask

What are the key benefits to clean URLs?

A clean URL is less intimidating to a human user. They can look at it and get an idea what the page is about. Clean URLs are also more sharable. Being short and meaningful, they are more pleasing to the eye and more likely to be shared on Twitter, Facebook, or other sites, and via email.

What is in URL stackoverflow?

It specifies an "Anchor", or a position on the page, and allows you to "jump" or "scroll" to that position on the page.


1 Answers

It's ASP.Net MVC, which has the .Net Routing more or less built in. The Routing is available for non MVC projects as well, though

http://msdn.microsoft.com/en-us/library/cc668201.aspx

It's just a .dll you can drop in your bin folder. Basically it uses regular expressions to match your URL's to pages/templates.

like image 115
Doug R Avatar answered Oct 08 '22 01:10

Doug R