Understing URL routing in MVC

mycoachmatch1

New Member
I am trying to create a very basic MVC framework to better understand the pattern.I am having trouble understanding the URL routing part.So far i've understood that the url carries 3 basic pieces of information in this format:www.site.com/controller/method/querystringSo given the following URL:\[code\]www.site.com/user/delete/john'user' is the controller'delete' is the method of said controller'john' is the query string\[/code\]In my framework, i have it so if a controller is not specified in the URL, it defaults to 'index'.If a method if not specified in the URL, it defaults to 'show'(which just outputs the html).this way i can go to www.site.com and since it doesn't have a controller or method in the url, thecontroller becomes 'index' and method 'show', thus just loading the index view.But what if i don't want to provide a method in the url, but just www.site.com/controller/querystringlike so:www.site.com/user/john This would ideally load the profile for John.But, the framework thinks 'john' in the url is the method to invoke, and not the query string. What is the standard, a practical way to distinguish between the two? ps:I have this in my .htaccess\[code\]RewriteRule ^(.*)$ index.php?$1 [L,QSA]\[/code\]echoing $_SERVER['QUERY_STRING'] in to http://site/profile/john gives 'profile/john'/
 
Back
Top