htaccess and MVC routing

牧云@^-^@ 提交于 2020-01-17 05:03:42

问题


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

Which gets the controller and tells it the function, just like CakePHP index(), view(), and so on.

Now, I'm not sure how I can make the url look like this with .htaccess

http://localhost/mvc/blog/viewall

I was trying to add this in the .htaccess file:

RewriteRule ^(.*)$ index.php?page=$1 [QSA]


回答1:


Have your redirect rule like this:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/mvc/index.php/.*
RewriteRule ^/mvc/(.*) /mvc/index.php?page=$1 [QSA,L]


来源:https://stackoverflow.com/questions/5332030/htaccess-and-mvc-routing

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