0

我有一个具有以下规则的 .htaccess 文件:

RewriteRule ^(boards)/(.+)/(.+)/(.+)/(.+)/([^./+])/?$ index.php?param0=$1&param1=$2&param2=$3&param3=$4&param4=$5&param5=$6 [NC]

RewriteRule ^(boards)/(.+)/(.+)/(.+)/([^./]+)/?$ index.php?param0=$1&param1=$2&param2=$3&param3=$4&param4=$5 [NC]

RewriteRule ^(boards)/(.+)/(.+)/([^./]+)/?$ index.php?param0=$1&param1=$2&param2=$3&param3=$4 [NC]

RewriteRule ^(boards)/(.+)/([^./]+)/?$ index.php?param0=$1&param1=$2&param2=$3 [NC]

RewriteRule ^(boards)/([^./]+)/?$ index.php?param0=$1&param1=$2 [NC]

RewriteRule ^(boards)/?$ index.php?param0=$1 [NC]

我的问题:是否有可能将它们组合成一个规则?保持这样的状态很烦人...

4

1 回答 1

1

如果你可以修改index.php,你可以这样做:

RewriteRule ^boards/(.*) index.php?url=$1 [NC]

并在里面解析$_GET['url']自己index.php

更好的是,你可以做到

RewriteRule ^boards/.* index.php [NC]

然后将$_SERVER['REQUEST_URI']自己解析为index.php.

于 2012-06-05T09:30:19.587 回答