我的网站使用简单的php。我已经从网址中删除了php exentesion,但是我想在网址末尾添加斜杠。我还添加了斜杠,但它给出了404错误。 http://example.com/testpage:有效 http://example.com/testpage/:不起作用
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://example.com/$1/ [L,R=301]
# Run Php without filename extension
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
# Return 404 if original request is .php
#RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
#RewriteRule .* - [L,R=404]