.htaccess - .htaccess code for multiple page of same directory
问题描述
I have near about 50 PHP page which is shown in address bar like -
http://www.example.com/STOP_WATCH/index.php
or
http://www.example.com/STOP_WATCH/second.php
for friendly url I was create a htaccess file with the following code-
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?
RewriteRule ^(.*)$ second.php?
-I have to know the rule for show the page like -
http://www.example.com/STOP_WATCH/second.
解决方案
以下代码适用于我:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
你可以看看这里。
推荐阅读
- java - 尝试通过正则表达式匹配字符串中可能的标签
- javascript - Webpack 4 + bootstrap [TypeError:无法读取未定义的属性'jquery']
- c# - .net core 3.1:剃须刀页面和 API 控制器的端点路由
- android-studio - Kotlin 上 !boolean (negative) 的等价物是什么
- c# - 为什么当我在 DataGrid 中做了一些更改时,我的 ObservableCollection 没有任何更改?
- node.js - Deno 简单静态 CRUD 示例
- javascript - 生成随机高度并应用于页面上的每个 div
- android-studio - 不借助 Sceneform 在 ARCore 环境中渲染对象
- json - 如果包含不同的结构,如何构建 REST API?
- flutter - Flutter:Alertdialog 和字体上的边框颜色