我已经在 php 中的 (.htaccess) 的帮助下隐藏了扩展名。如果任何用户在 URL 框中写入扩展名,则会出现错误,页面不存在。
例如---> index.php注释存在
但是---->索引存在
最佳答案
您可以尝试组合RewriteRule和 RedirectMatch
# RedirectMatch for urls with .php extension
RedirectMatch 404 ^(.+)\.php$
# RewriteRules for not files && not directoris to php files
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)$ $1.php [L]
关于php - 我已经在 php 中的 .htaccess 的帮助下隐藏了扩展名,但我想要。如果任何用户在 URL 框中写入扩展名,则会出现错误,页面不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36240045/