I have noticed that in Stackoverflow, there are basically 4-6 kinds of different URLs. One is for questions, like http://stackoverflow.com/questions/6831217/double-vs-decimal-in-mysql
. One is for user profile page, like http://stackoverflow.com/users/1469954/cupidvogel
. One is for new question, like http://stackoverflow.com/questions/ask
, etc.
With each page request, the server sends a page as required. Now how do I achieve this on the server side? Should there be one catchall PHP script, which will parse the URL to note what type of page is the client asking (for example, if it parses the URL and finds out that the client is asking for a topic page, it will perhaps extract the question id/text from the URL, query the DB to fetch relevant data, construct the HTTML and send it) and send it accordingly, or should there be separate scripts for each page type? And for either, how do I configure PHP/Apache for this?
If I have a page like foo.php, I can see it through http://localhost/foo.php
. But if I want it to capture http://localhost/foo.php
as well as http://localhost/foo.php/ask/questions
, etc, what do I have to do?