2014-02-05 41 views
1

我閱讀了很多關於使用來自stackoverflow的htaccess進行兩次mod重寫的討論。但是對我來說沒有任何效果。這是我的網址,www.website.com/image.php?category=animals&name=tiger,我想將其更改爲乾淨的網址,如下所示。 http://www.website.com/animal/tiger使用htaccess重寫兩個參數的URL使用htaccess

<IfModule mod_rewrite.c> 

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)$ category.php?tag=$1 [NC] 


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+)$ covers.php?tag=$1&name=$2 [L] 

</IfModule> 

www.website.com/animal/tiger運作良好,但是當我點擊(類別)www.website.com/animal/,它沒有顯示結果。

回答

1

我認爲你缺少規則結尾斜線檢查:

<IfModule mod_rewrite.c> 

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/?$ category.php?tag=$1 [NC] 


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+)/?$ covers.php?tag=$1&name=$2 [L] 

</IfModule> 

請嘗試。