0

我目前正在开发一个 Web 应用程序,并在确定路由请求的 htaccess 规则时卡住了。

我想要这样的东西(m=module,a=action,o=object of action):

www.domain.com/m/a/o

对于一般要求,我打算这样做(o 为空):

www.domain.com/users/login
to: www.domain.com/index.php?m=users&a=login
www.domain.com/users/logout
to: www.domain.com/index.php?m=users&a=logout

但是对于站点范围的路由,我想要:

www.domain.com/projects/show/123
to: www.domain.com/index.php?m=projects&action=show&object=123

一般来说,我想为重定向设置我的 .htaccess 规则,如下所示:

www.domain.com/EMPTY 
    to: www.domain.com?index.php
www.domain.com/([^-]a-z0-9) 
    to: www.domain.com?index.php?m=$1
www.domain.com/([^-]a-z0-9)/([^-]a-z0-9) 
    to: www.domain.com?index.php?m=$1&a=$2
www.domain.com/([^-]a-z0-9)/([^-]a-z0-9)/([^-]a-z0-9) 
    to: www.domain.com?index.php?m=$1&a=$2&o=$3

你能帮忙吗?

我尝试过这样的事情,但失败的时间超过了域本身:

RewriteRule ^/([^-]a-z0-9+)$ index.php?m=$1 [L]
RewriteRule ^/([^-]a-z0-9+)/([^-]a-z0-9+)$ index.php?m=$1&a=$2 [L]
RewriteRule ^/([^-]a-z0-9+)/([^-]a-z0-9+)/([^-]a-z0-9+)$ index.php?m=$1&a=$2&o=$3 [L]
4

0 回答 0