.htaccess重写505错误循环

我正在重写:

mydomain.com/category.php?id=cat

mydomain.com/cat

我使用了下面的.htaccess代码,但它一直显示一个505错误:

RewriteEngine On RewriteRule ^([^/]*)$ /category.php?id=$1 [L] 

我在另一个页面上阅读,这是因为页面不断循环,但我无法解决如何修复代码。

保持这样的规则:

 RewriteEngine On # If the request is not for a valid directory RewriteCond %{REQUEST_FILENAME} !-d # If the request is not for a valid file RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/?$ /category.php?id=$1 [L,QSA] 

尝试这个。

 <Ifmodulee mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^(\w+)/ category.php?id=$1 [L] </Ifmodulee> 

你需要添加RewriteCond来避免重写category.php

 RewriteEngine On RewriteCond %{REQUEUST_URI} !^ /category.php/(.*) RewriteRule ^(\w+)/ category.php?id=$1 [L] 

好吧,这应该工作:

 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/category.php RewriteRule ^(.*)$ category.php?id=$1 [R=301,L] 

演示: http : //ht6.valhook.com/cat