I want to execute php if directory of the same name not found.It works well on Wamp because it's already configured in its Apache httpd.conf but I don't know what to do with .htaccess.
EX: www.example.com/directory1/directory2/...../.......
Actually There's no directory1 folder in the root but there's only a php file name "directory1.php"
so I want www.example.com/directory1/directory2/ to execute a php file name "directory1.php"
if the folder of that name is not found.
In Short, If there's a folder it'll follow that folder directory but if no folder then it'll execute the first directory which is in php file after website url without .php extension.
So That php should be able to execute with slash behind "www.example.com/directory1/" or without slash "www.example.com/directory1".
使用.htaccess执行php如果找不到相同名称的目录
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- dongyue8640 2017-10-20 11:56关注
Check if the requested URL neither a directory nor a file, then rewrite to the PHP file with the Name of the first folder
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ([^/]+) $1.php
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
- ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
- ¥15 matlab有关常微分方程的问题求解决
- ¥15 perl MISA分析p3_in脚本出错
- ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
- ¥15 ubuntu虚拟机打包apk错误
- ¥199 rust编程架构设计的方案 有偿
- ¥15 回答4f系统的像差计算
- ¥15 java如何提取出pdf里的文字?
- ¥100 求三轴之间相互配合画圆以及直线的算法