简体   繁体   中英

Ghost directories/files with php?

I was wondering how Wordpress and other random forums and sites, like facebook, create like phantom directories? Eg, a blog might have 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- ? Is that a physical directory, or is it simply a scripting trick? How can I do this with PHP?

That kind of functionality is normally achieved by instructing the web server to "link" certain URL patterns to a specific controller.

See .htaccess , for example.

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.

PHP can certainly handle this, but it's the web server that needs to be instructed on how to handle those types of request. If you're using apache you might want to take a look at some mod_rewrite tutorials .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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