Reputation: 4582
I am not sure on how to search this on google. Maybe someone could explain instead. How does a website, like stack overflow, have urls "http://stackoverflow.com/questions/..somenumber../the-title-of-the-question-or-something-like-that
and its able to bring up that webpage with that question. Could someone explain to me how that is done? Is it some form of javascript? I was trying to think through this problem and how it would be done, but it confuses me. I am also a rookie when it comes to web development.
Upvotes: 2
Views: 250
Reputation: 99
That "somenumber" is the ID of the question in the database. Anything that comes after the somenumber/ is for SEO purposes. That's why all these links work.
http://stackoverflow.com/questions/4229090/website-url-how-does-stack-overflow-work
http://stackoverflow.com/questions/4229090
http://stackoverflow.com/questions/4229090/foobar
Its just referencing that ID to pull up the question
Upvotes: 2
Reputation: 943142
In the case of SO, a server side process extracts the question number (4229090) from the URL and ignores the rest (website-url-how-does-stack-overflow-work). It uses the number for database lookups.
There are lots of different ways to extract that number. The specifics depend on your programming environment.
Upvotes: 0
Reputation: 887275
StackOverflow uses the ASP.Net MVC Framework, which allows you to create arbitrary URL routes that are handled by action methods.
You can also do this using ASP.Net routing; similar frameworks are available for other platforms.
On a lower level, the browser sends a request to the web server containing an arbitrary path; the server can do whatever it wants to with that path to send a response.
There is no intrinsic relation between paths in URLs and a filesystem.
Most webservers will usually serve the contents of the file at the path, but this is not required.
Upvotes: 6