Code Igniter 如何知道index.php 不是一个目录?

发布于 2024-09-28 09:33:18 字数 385 浏览 2 评论 0原文

我的 Code Igniter 应用程序的网址如下:

http://servername/contexttroot/index.php/Sessions /login/

我的问题是,当解析url时,Apache如何知道不存在名为index.php的文件夹?如果我是解析器,这就是我要寻找的:)

我知道它可以工作并且 CI 的 index.php 被调用,但我不明白它是如何工作的。也许不允许点作为目录名称的一部分?

更新有关详细信息,请参阅已接受问题的评论,我要问的内容有很多细节。

My Code Igniter app has urls like this:

http://servername/contexttroot/index.php/Sessions/login/

My question is, when the url is parsed how does Apache know that there isn't a folder called index.php? If I were the parser, that's what I would be looking for :)

I know it works and CI's index.php gets called but I don't understand how this works. Maybe dots aren't allowed as part of directory names?

UPDATE See the comments on the accepted question for details, there are lots of details to what I am asking.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔梦 2024-10-05 09:33:18

CodeIgniter 基本上通过在 URL 中搜索索引文件名“index.php”来执行 URL 重写。查看 CI 的配置文件中的这一行:

$config['index_page'] = "index.php";

尝试将其更改为其他内容,看看它是否仍然有效。

编辑:好的,回答Juan提出的问题,Apache知道index.php不是目录的方式是因为文件和目录在同一目录中不能具有相同的名称。如果index.php只是一个目录,Apache会进入它并进一步搜索。如果它是一个文件,它将运行该文件。

CodeIgniter basically performs rewrites of the URL by searching for the index file name "index.php" in your URL. Look in CI's config file for this line:

$config['index_page'] = "index.php";

Try changing that to something else and see if it still works.

Edit: OK, to answer the question Juan posed, the way Apache knows that index.php isn't a directory is because a file and directory can't have the same name in the same directory. If index.php were simply a directory, Apache would go into it and search further. If it is a file, it will run the file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文