我对我的.htaccess
文件有疑问,键入 domain.com/about 时它不会显示该文件,而不是 domain.com/about.php
这是我的.htaccess
代码(它适用于本地主机),我正在使用 ubuntu 和 apache2 网络服务器
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]
使用
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^'.]+)$ $1.php [NC,L]