.htaccess RewriteEngine RewriteRule 3静态参数,递归通用参数

时间:2016-12-02 13:23:37

标签: .htaccess mod-rewrite

所以想要完成(使用.htaccess)我可以重写这个url:

  ?

的index.php控制器= ControllerName&安培;方法=&方法名放大器;图= VIEWNAME&安培;键=值&安培;键2 =值

对此:

  

/ ControllerName /方法名/ VIEWNAME /键=值&安培;键2 =值

这是我现在的代码:

RewriteEngine On

RewriteRule ^(.*)/(.*)/(.*)/(.*) index.php?controller=$1&method=$2&view=$3&$4=$5 [L]
RewriteRule ^(.*)/(.*)/(.*)/ index.php?controller=$1&method=$2&view=$3 [L]

1 个答案:

答案 0 :(得分:1)

尝试此规则,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ index.php?controller=$1&method=$2&view=$3 [QSA,L]