php - 只需在 url 中写入 /mvc/ 并删除 .php 即可访问 /mvc/public/index.php
问题描述
我正在学习 mvc 概念,我发现了一个视频,其中他做了一些更改,但是当我编写与他编写的相同代码时,这些更改并未应用。我的意思是没有写 php 但他在 .htaccess 文件中做了一些更改
我的问题是,我的文档根目录是c/xampp/htdocs/mvc/public/index.php
,当我编写时localhost/mvc
,里面的所有文件和文件夹都出现在 mvc 中,我不希望这样。我希望将其直接重定向到mvc/public/index.php
页面,并且扩展名 .php 不应出现在 url
我在索引文件中的代码
echo "request url " . $_SERVER['REQUEST_URI'];
并且该.htaccess
文件位于公共文件夹中并且是
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
解决方案
推荐阅读
- pandas - 对于十六进制数,如何按位反转列中的每个值?
- ios - `hasAmbiguousLayout` 是真的,但 `exerciseAmbiguityInLayout()` 什么都不做?
- python - tkinter tic-tac-toe 的重启按钮
- javascript - 使用 node.js 在 JSON 文件中添加嵌套数组
- php - 为什么我的 jquery 调用刷新页面?
- python - 使用 Mask-RCNN 或 Unet 计算多株苗的角度
- python-3.x - 签名以请求 jwt 以在 python3 中的 API 上使用
- jmeter - HTTP 授权管理器
- python - 无法以我想要的方式检查输入 - Python
- javascript - 承诺拒绝没有被抓住