php - 如何在 .htaccess 中使用一行代码隐藏 php 扩展
问题描述
我想问的是,不要在 .htaccess 中写很多行,包括所有页面来隐藏它们的扩展名,比如
RewriteRule ^about$ about.php [L]
RewriteRule ^register$ register.php [L]
RewriteRule ^login$ login.php [L]
RewriteRule ^dashboard$ dashboard.php [L]
RewriteRule ^logout$ logout.php [L]
是否有任何单行代码可以做到这一点?
解决方案
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
推荐阅读
- c++ - 如何为我的进程更新 PROC_THREAD_ATTRIBUTE_LIST?
- date - Google 表格中报告的查询公式有问题
- azure - Azure 容器级别访问
- python - Create discrete colorbar
- azure - How to fix 'not support yet' error Cassandra run in Azure service?
- javascript - react-native open a modal inside a modal
- linux - Basic if else scripting
- dart - Set height of DropdownButtonFormField list
- django - Unable to view content in DetailView Django
- c++ - 输入有效输入值后仍然提示