2014-10-01 56 views
1

我有這個在我的.htaccess不工作MOD-改寫預期

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7&h=$8&i=$9&j=$10&k=$11&l=$12&m=$13 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7&h=$8&i=$9&j=$10&k=$11&l=$12 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7&h=$8&i=$9&j=$10&k=$11 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7&h=$8&i=$9&j=$10 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7&h=$8&i=$9 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7&h=$8 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3&d=$4 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/(.*)$ index.php?a=$1&b=$2 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?a=$1 [QSA,L] 

它能做什麼,是重寫一樣的東西:

http://www.domain.com/project/backend?a=moderate&b=overview&c=29&d=stoptober&e=page&f=1&g=filter&h=no-twitter&i=no-instagram&j=test&k=test2&l=no-text

http://www.domain.com/project/backend/moderate/overview/29/stoptober/page/1/filter/no-twitter/no-instagram/test/test2/no-text

但是,當我var_dump這一點,顯示此:

array(12) { 
    ["a"]=> 
    string(8) "moderate" 
    ["b"]=> 
    string(8) "overview" 
    ["c"]=> 
    string(2) "29" 
    ["d"]=> 
    string(9) "stoptober" 
    ["e"]=> 
    string(4) "page" 
    ["f"]=> 
    string(1) "1" 
    ["g"]=> 
    string(6) "filter" 
    ["h"]=> 
    string(10) "no-twitter" 
    ["i"]=> 
    string(12) "no-instagram" 
    ["j"]=> 
    string(9) "moderate0" 
    ["k"]=> 
    string(9) "moderate1" 
    ["l"]=> 
    string(9) "moderate2" 
} 

這怎麼可能?更重要的是,我該如何解決這個問題?

回答

1

Backreferences包括在$0$9之間。

如果你嘗試$10這是一樣$10末,這也解釋moderate0$1 = moderate)。

解決方案:你需要減少你的參數。這是一個URI的設計問題


編輯:如果你想避免重複的條件,你可以做如下

RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule^- [L] 

# all your RewriteRule here 
+0

我在閱讀您的評論後已經這麼認爲,但在創建此問題後我閱讀了您的評論 – SheperdOfFire 2014-10-01 09:47:02

0

試試這個..這將作爲你想的一樣..您可以根據您的要求更改鏈接名稱...

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    Options -Indexes 
    RewriteEngine On 

    RewriteRule ^([^/]*)/$ index.php?select=$1 [L] 
    RewriteRule ^([^/]*)/$ ?select=$1 [L] 
    RewriteRule ^([^/]*)/([^/]*)/$ index.php?select=$1&a=$2 [L] 
    RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ index.php?select=$1&a=$2&b=$3 [L] 
    RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ index.php?select=$1&a=$2&b=$3&c=$4 [L] 

    RewriteCond %{REQUEST_URI} /+[^\.]+$ 
    RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L] 

</IfModule>