简体   繁体   English

鬼目录/文件与PHP?

[英]Ghost directories/files with php?

I was wondering how Wordpress and other random forums and sites, like facebook, create like phantom directories? 我想知道Wordpress和其他随机论坛和站点(如Facebook)如何创建像幻像目录? Eg, a blog might have http://www.joesblog.com/2010/11/12/this-is-my-post.php 例如,博客可能具有http://www.joesblog.com/2010/11/12/this-is-my-post.php

Does that file and directory resource actually exist? 该文件和目录资源实际上存在吗? Also, how does Facebook, for example, have like http://www.facebook.com/-usernamehere- ? 另外,例如,Facebook如何像http://www.facebook.com/-usernamehere- Is that a physical directory, or is it simply a scripting trick? 那是物理目录,还是仅仅是脚本技巧? How can I do this with PHP? 我该如何使用PHP?

That kind of functionality is normally achieved by instructing the web server to "link" certain URL patterns to a specific controller. 通常,通过指示Web服务器将某些URL模式“链接”到特定控制器来实现这种功能。

See .htaccess , for example. 例如,请参阅.htaccess

EDIT: This article on Rewrite engine might also help. 编辑:有关重写引擎的这篇文章也可能会有所帮助。

So no, no directories actually exist. 所以不,实际上没有目录。 The web server receives a request for a specific URI and redirects that request to a delegated controller (that can be a PHP script, for example) that in turn returns a result based on the URI and action requested by the user. Web服务器接收对特定URI的请求,并将该请求重定向到委托控制器(例如,可以是PHP脚本),该控制器又根据URI和用户请求的操作返回结果。

PHP can certainly handle this, but it's the web server that needs to be instructed on how to handle those types of request. PHP当然可以解决这个问题,但是需要指导Web服务器如何处理这些类型的请求。 If you're using apache you might want to take a look at some mod_rewrite tutorials . 如果您使用的是Apache,则可能需要看一下mod_rewrite教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM