为了避免用户访问文件夹。我将以下代码设置为 .htaccess 文件
Order allow,deny
Deny from all
<FilesMatch ".*\.(css|js|php)$">
Allow from all
</FilesMatch>
用户只能打开 .css .js .php 文件。
但我想隐藏 .php 扩展名并允许用户访问任何文件扩展名。
所以我使用以下代码来隐藏扩展名 .php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} \.php[/\s?] [NC]
RewriteRule ^ - [F]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
</IfModule>
知道如何让用户使用 .htaccess 不允许文件扩展名访问吗?
非常感谢