href=";blaah”;而不是href=“”;blaah.php”;以及href="";而不


href="blaah" instead of href="blaah.php" and href=".." instead of href="index.php"

我看到a标记的href属性使用了href="blaah"而不是href="blaah.php"。我也看到了href=".."而不是href="index.php"

我已经在NGINX服务器上测试过这一点,但当我托管时,我可能最终会通过Apache托管。那么,Apache支持href="blaah"吗?

您可以使用RewriteEngine,只需将此代码添加到.htaccess.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}'.php -f
RewriteRule ^(.+)$ $1.php [L]

这段代码将.php添加到每个没有扩展名的文件中。