apache mod_rewrite 500内部错误

时间:2014-04-17 03:23:42

标签: php apache .htaccess mod-rewrite

我想改变

http://localhost/inbox?pg=2

http://localhost/inobox/2

我得到了一个如下工作代码

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteRule ^/?inbox/(\d+)$ /inbox?pg=$1 [QSD,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [QSA,L]
然而,如果我改变了 http://localhost/inbox/2

http://localhost/inbox/2.5http://localhost/inbox/ 我得到500错误,我无法弄清楚是什么导致它。我已经在php端检查空var或非数值但是,每次我更改它时,这500错误就会发生,如果有其中一种情况发生,有人知道如何重定向回inbox.php吗?

日志文件读取 r->uri = /inbox/2.5.php.php.php.php.php.php.php.php.php.php

redirected from r->uri = /inbox/2.5.php.php.php.php.php.php.php.php.php

1 个答案:

答案 0 :(得分:0)

RewriteRule ^/?inbox/(\d+)$ /inbox?pg=$1 [QSD,L]中,\d仅匹配数字字符0-9而不匹配.,因此2.5与此规则不匹配。要匹配2和2.5,请改用([\d.]+)