Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

how can I configure Apache server, to mantain requests such as: http://developers.facebook.com/docs/reference/fql/ (i mean the /one/two/three)?

What's the name of this technique and how it is done?

Thanks.

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

You can do that with Apache Forcetype.

Typically a web server knows how to handle requests by the extension any given file has. For instance, if a file has a .php extension Apache knows to parse it for PHP code before sending it to the browser. Apache's ForceType directive allows you to override any default mime types you have set up. Usually it may be used to parse an .html page as php or something similar, but in this case we will be using it to parse a file with no extension as php.

So instead of using article.php, as we did in method 1, rename that file to just "article" with no extension. You will be able to access it like this: http://www.domain.com/article/999/12/. Utilizing Apache's look back feature and $PATH_INFO variable as described in method 1. But as of right now Apache doesn't yet know to that "article" needs to be parsed as php. To achieve that you must add the following to your .htaccess file.

<Files article> ForceType
    application/x-httpd-php  
</Files> 

This is known as a container. Instead of applying directives to all files Apache allows you to limit them by filename, location, or directory. You need create a container as above and place the directives inside it. In this case we are using a file container, we identify "article" as the file we are concerned with and then we list the directives we want applied to this file before closing off the container.

With the directive inside the container we are telling Apache to parse "article" as a php script even though it has no file extension. This allows us to get rid of the period in the URL that causes the problems yet still use the PATH_INFO method to manage our site.

share|improve this answer
    
how it is done for example on Facebook where there is a lot of such pages? Majority of users have their own site: http://www.facebook.com/username. I don't think that they create for every user <Files username> ForceType application/x-httpd-php </Files> –  Dupadupa Jun 10 '11 at 19:55
    
They could be using mod_rewrite. There is definitely more then one way to do this. –  John Conde Jun 10 '11 at 20:23
add comment

Most sites with this structure would use mod_rewrite to rewrite all requests to a single file, which would bootstrap a framework or CMS. The CMS or framework would then read and parse the URI and handle internally as designed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.