MVC URL yönlendirme Understing

0 Cevap php

Ben daha iyi modelini anlamak için çok temel bir MVC çerçevesi oluşturmak için çalışıyorum.

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/querystring

Yani aşağıdaki URL'yi verilen:

www.site.com/user/delete/john

'user' is the controller
'delete' is the method of said controller
'john' is the query string

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, the controller 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/querystring like 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.

Standart, ikisi arasında ayrım pratik bir yolu nedir?

ps:

Benim. Htaccess bu var

RewriteRule ^(.*)$ index.php?$1 [L,QSA]

için $ _SERVER ['QUERY_STRING'] yankılanan http://site/profile/john 'profili / john' verir /

0 Cevap