htaccess URL routing for PHP MVC?

守給你的承諾、 提交于 2020-01-07 02:11:48

问题


I've been searching and have yet to find an article to help me. I'm very unfamiliar when it comes to the rewrite engine of htaccess files, and am currently developing a php mvc framework.

Basically, from the root of the webserver, I need all page requests with their controllers / actions in the url to redirect to App/index.php

So, for example site.com/Login/ would direct to the index.php, and the uri would obviously be parsed out with php to enact the login controller with passed post data.


回答1:


I think the 'usual' way is to forward all requests for non-existent files and directories to your controller:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ App/index.php [L]


来源:https://stackoverflow.com/questions/7693788/htaccess-url-routing-for-php-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!