htaccess的URL路由的PHP MVC? [英] htaccess URL routing for PHP MVC?

查看:158
本文介绍了htaccess的URL路由的PHP MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找,并还没有找到一篇文章,以帮助我。我很熟悉,当涉及到的htaccess的文件重写引擎,和我目前正在开发一个PHP MVC框架。

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.

基本上,从网络服务器的根目录下,我需要他们的控制器的所有页面请求/ url中的操作重定向到应用程序/ index.php的

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

因此​​,例如site.com/Login/就直接到的index.php,和URI显然被解析用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.

推荐答案

我觉得'平常'的方式是转发的不存在的文件和目录到控制器的所有请求:

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]

这篇关于htaccess的URL路由的PHP MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆