Reputation: 5921
I know how these kind of URLs load the page ... based on their GET parameter.
http://www.bedupako.com/songs.php?page=show_song_details.php&songid=1167&n=0&back=no
and in the back-end roughly something like this:
<?php
switch($_GET['page']) {
case 'xx': include('my page');break;
.
.
.
default: include('default');break;
}
?>
But how do these kinds of URLs work? I mean, how is the data loaded dynamically?
www.dummysite.com/parm/subpage1/xyz
www.dummysite.com/parm/subpage2/xyz
How are these parsed similar to the GET param like websites?
Upvotes: 3
Views: 899
Reputation: 60403
You can use mod_rewrite by itself as others have suggested, but most sites do not do this because its not very flexible, and can be annoying to maintain if you have more than a couple of these "pretty" URLS.
Instead they set up a basic rewrite rule to forward everything to a single index.php and then on the application side they parse the URI based on defined patterns - these are called "routes". Route parsing usually happens in some kind of routing class which process the defined routes and compares them to the URI, and then when it finds a match parses out the parameters for the matched route.
These all provide good examples of a router, but they are hard to understand without the other interacting classes:
Zend_Controller_Router_Rewrite
sfPatternRouting
Router
CI_Router
Upvotes: 1
Reputation: 2860
You should look at http://httpd.apache.org/docs/2.0/misc/rewriteguide.html url rewriting if you're with apache (most likely)
Upvotes: 1
Reputation: 8334
In most cases this will be handled by the web server on-the-fly according to a set of rules. The specifics of it will vary from server to server and on a case-by-case basis. In Apache it is usually done using the mod_rewrite extension.
Upvotes: 2