Code Igniter 如何知道index.php 不是一个目录?
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CodeIgniter 基本上通过在 URL 中搜索索引文件名“index.php”来执行 URL 重写。查看 CI 的配置文件中的这一行:
尝试将其更改为其他内容,看看它是否仍然有效。
编辑:好的,回答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:
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.