【发布时间】:2014-05-16 06:07:37
【问题描述】:
有没有一种方法可以让我使用 htaccess 的 url 重写功能看起来像有一个文件,比如说 /public/some/folder,而实际上它在 /public 中。
例如,我在根文件夹中有 index.php,我希望它在我访问 index.php 时也像它在所有文件夹和子文件夹中的行为一样
当我执行 index.php 时,它也会在所有文件夹和子文件夹中执行
更新
请通过下面的例子理解我的问题
index.php 在根目录下,我在根目录下也有不同的文件夹 所以当我通过浏览器访问 index.php 时,它也会在其他文件夹中执行
http://example.com/index.php 也将表现得好像它也在子文件夹中一样
http://example.com/folder1/index.php
http://example.com/folder2/index.php
http://example.com/folder3/index.php
index.php 不在这些文件夹中,但它也必须同时在这些文件夹中执行
我觉得通过这个例子不难理解,请相应回答
【问题讨论】:
-
你的意思是像 index.php?page=category&subcat=tet 更改为 example.com/category/test ?
-
@Soundz NO 不会更改,但 index.php 应该表现得好像它也在其他文件夹中一样,而无需手动将 index.php 上传到每个文件夹我只想在主文件夹中拥有 index.php 并且想要同时在其他文件夹中执行它
-
换句话说,您想阻止对包含图像/文件的文件夹编制索引?
标签: php .htaccess mod-rewrite url-rewriting rewrite