且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在不使用.htaccess的情况下隐藏PHP文件扩展名

更新时间:2022-11-03 13:15:51

尽管您明确表示不,但使用.htaccess文件将删除站点中所有子目录中所有PHP文件中的.php扩展名.我想这就是你要的.

Although you specifically said no, using the .htaccess file would remove the .php extension from all PHP files in all subdirectories in a site. I think that is what you are going for.

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^(.*)$ $1.php
</IfModule>

将其放入.htaccess文件将删除所有.php文件扩展名. 或者,您可以将其直接放入Web服务器的配置文件中.

Putting that into the .htaccess file will remove all the .php file extensions. Or you could put it directly into the webserver's configuration files.