mod_rewrite导致err_too_many_redirects

时间:2016-03-13 22:52:35

标签: apache .htaccess mod-rewrite

我的.htaccess文件是这样的:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ user.php?u=$1 [NC]
RewriteRule ^albums/(.*)$ albums.php?gallery=$1 [NC]

关于用户页面的规则(user.php)有效,但关于相册页面的规则(albums.php)会导致此错误:

  

err_too_many_redirects

1 个答案:

答案 0 :(得分:1)

重新排序您的规则:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]

RewriteRule ^albums/(.*)$ albums.php?gallery=$1 [L,NC]
RewriteRule ^(.*)$ user.php?u=$1 [L,NC]