让我说我有这个:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^page(?:/error(?:/([^/]+))?)?/?$ page.php?error=$1 [L,QSA]
page/
及以后(page/error/
等)给我500错误。
答案 0 :(得分:1)
您可以使用此规则将最后一个斜杠和其他URI组件设为可选:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^page(?:/error(?:/([^/]+))?)?/?$ page.php?error=$1 [L,QSA]
完整.htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^page(?:/error(?:/([^/]+))?)?/?$ page.php?error=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]