开发者

Mod_rewrite Rules for MVC Architecture

In my site you can open pages like this...

example.com/?controller=index&action=index

I want to make links nicer so I use mod_rewrite...

RewriteRule ^([^/]+)/(.*)$  index.php?controller=$1&action=$2 [L,QS开发者_开发知识库A]

It works perfectly and result is somehow like this...

example.com/index/index

But my problem is that this link, where is set only the 1st variable won't work. Don't know how to fix it! This won't work...

example.com/index


Do something like this:

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/(.*)$ index.php?mod=$1&act=$2 [QSA,L]

RewriteRule ^([a-zA-Z0-9_-]+)/(.*)$ index.php?mod=$1 [QSA,L]

RewriteRule ^(.*)$ index.php [QSA,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜