2012-07-10 41 views
0
 
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^([a-zA-Z0-9_-]+)$ index.php/$1 [L] 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php/$1/$2 [L] 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php/$1/$2/$3 [L] 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php/$1/$2/$3/$4 [L] 

你可以看到我的代碼..我想知道的.htaccess規則

$ 1/$ 2/$ 3/$ 4。(現在)

$ 1/$ 2/$ 3/$ 4/$ 5〜$無限的(我想)

對不起我的英文不好..

你懂嗎?

回答

1

如果你想無限([a-zA-Z0-9_-]+)/的,你可以只匹配[a-zA-Z0-9_-/]+和收工:

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^([/a-zA-Z0-9_-]+)$ index.php/$1 [L] 
+0

我用這個代碼,我得到500錯誤 – Notice 2012-07-10 23:16:20

+0

對不起,第一個'/'是在錯誤的地方,現在試試吧。還要確保你有其餘的條件在上面(只替換規則) – 2012-07-10 23:19:51

+0

感謝你我找到了一種方法/ RewriteRule ^(。*)$ index.php/$ 1 [L] / – Notice 2012-07-10 23:20:43