URL routing vs multiple scripts

I'm trying to understand the benefits of using a URL routing (URL dispatch) over just running code from different scripts. Besides prettier urls (which can be accomplished via htaccess using either model), why would I direct /archive/ to dispatcher.php?path=/archive/ instead of, say, simply rewriting /*/ to *.php? Is either one better in terms of code reuse? Organization? Error handling?

Have you ever switched from one model to the other? Why did you do so? How much work did the switch entail?

For context, I am currently using the multiple script method. The environment is Apache + PHP. It is a medium size project (40+ top level php pages).


One major advantage of routing is that you can do so conditionally, making decisions on where addresses route based on user data, session values, time of day, or whatever. Most of my projects are too simple to use this method, but if you get into a more complex system, I think the having control over routing in the code gives you some extra power and options.

Need Your Help

Saving the file and progress bar


I want user to type the name of the file with the location where he/ she wants to save the file. How can I do this? My code is as follows. Right now the location is fixed but I want it to be a vari...

Best practice to build html from json / js object?

javascript jquery ajax json api

When I get an ajax response from the API, I get a hard json structure:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.