I am not sure how to do mod-rewrite for the modular structure of MVC. What I want to do is capture URLs:
http://domainname.com/index.php?model={model}&view={view}¶meters={parameters}
NOTE: the parameters will be in a certain order and divided by pipes (if there is no better way): parameters = param1 | param2 | param3
http://domainname.com/{model}/{view}/{parameters}
Example:
http://domainname.com/faq/edit/13
Another example:
http://domainname.com/faq/index/{sort}/{page}/{search}
http://domainname.com/faq/index/asc/3/How+to
Essentially, something after the model and presentation will and can be parameters; as required. For each view, I will know the possible parameters that are valid for the region and in what order.
Thanks in advance.
-
Using the code below, this is what I have:
Rewriteengine on
RewriteCond% {REQUEST_FILENAME}! -F
RewriteCond% {REQUEST_FILENAME}! -D
RewriteRule ^ (. *) / (. *) / (. *) Index.php? Model = $ 1 & view = $ 2 & parameters = $ 3 [L, NS]
URL: http://localhost:8888/testing/faq/index/asc/5/How+to
PHP variables $ _GET:
Array
(
[model] => faq/index/asc
[view] => 5
[parameters] => How to
)
:
Array
(
[model] => faq
[view] => index
[parameters] => asc/5/How to
)
,