htaccess和MVC路由 [英] htaccess and MVC routing
问题描述
好吧,我开始编写一个微型MVC基础代码,我可以在客户端网站上使用它,它也使用与CakePHP相同类型的路由器类.我目前的网址显示如下:
Well i started coding a mini MVC base that I can just use on client websites, which also uses the same type of router class as CakePHP. I currently have the url display like this:
http://localhost/mvc/index.php?page=blog/viewall
哪个获取控制器并告诉其功能,就像CakePHP index(),view()等等.
Which gets the controller and tells it the function, just like CakePHP index(), view(), and so on.
现在,我不确定如何使用.htaccess使网址看起来像这样
Now, I'm not sure how I can make the url look like this with .htaccess
http://localhost/mvc/blog/viewall
我试图将其添加到.htaccess文件中:
I was trying to add this in the .htaccess file:
RewriteRule ^(.*)$ index.php?page=$1 [QSA]
推荐答案
具有这样的重定向规则:
Have your redirect rule like this:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/mvc/index.php/.*
RewriteRule ^/mvc/(.*) /mvc/index.php?page=$1 [QSA,L]
这篇关于htaccess和MVC路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!