我有这个代码将domain.com/Birthdays/birthdays.php?n=Something转换为domain.com/Birthdays/Something,并将.php和.html转换为其他页面:
RewriteEngine on
RewriteRule ^Birthday/(\w+)$ /Birthdays/birthdays.php?n=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
当我添加此问题时,问题出现了:
RewriteEngine on
RewriteRule ^Birthdays/(.*)$ [L]
RewriteRule ^Birthday/(\w+)$ /Birthdays/birthdays.php?n=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
它给了我一个错误(500),但是如果我将(。*)更改为(\ w +)它就可以了。但我不希望这样。
答案 0 :(得分:0)
您可以使用:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Birthday/(\w*)$ /Birthdays/birthdays.php?n=$1 [L,QSA]
由于循环错误,您获得500,因为规则的模式匹配起始和重写的URI。