我对我的.htaccess
文件有疑问,在输入domain.com/about时,它不会显示该文件,而不是domain.com/about.php
这是我的.htaccess
代码(适用于localhost),我使用的是ubuntu和apache2 webserver
RewriteEngine on
# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
答案 0 :(得分:2)
使用
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]