2012-06-05 62 views
0

我有以下規則.htaccess文件: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] 

我的問題:有可能結合這些逼到一個規則?這是很煩人保持這樣的... ...

回答

1

如果你可以修改index.php,你可以這樣做:

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

和自己解析$_GET['url']index.php

更妙的是,你可以做

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

,然後自己分析$_SERVER['REQUEST_URI']index.php

+0

這是一個相當不錯的主意〜我會試試看:) – foaly

+0

我用這個現在: 重寫規則^(404個|板)/.*$的index.php模塊= $ 1 [NC] 所有? '模塊的我在括號裏。 – foaly