Take the 2-minute tour ×

I'm wondering how sites these days are managing their content and AJAX calls.

How is it that Facebook is able to have a URL like: http://www.facebook.com/zuck

without with / on the end of zuck like http://www.facebook.com/zuck/

This is obviously really handy as they don't actually need to create a sub-directory called zuck.

I noticed as well that places like http://hypem.com/popular is doing it too. Convenient for them as they're able to run their media player without breaks and they don't need to to have a # in their URL.

share|improve this question

closed as unclear what you're asking by Musa, Mr. Alien, vladr, BeatAlex, Paul-Jan Mar 6 at 12:27


The answer is .htaccess URL Rewrite –  Mr. Alien Nov 15 '12 at 4:31
URLs don't have to map to a filestem! zuck/ does not have to be a directory somewhere. Some applications take the URL and map it to a filesystem, some don't (take Ruby on Rails and its map.resources.) And I don't understand why on Earth you came to think that the trailing slash, #, or absence thereof have anything to do with smooth media playback! :) –  vladr Nov 15 '12 at 4:34

3 Answers 3

this kind of URL mostly uses the Apache redirect rules in .htaccess files, you will see something like domain.com/example but in the back-end it is really mean redirect this to something like


so they dont want users see the exact pattern of their system.

share|improve this answer

This is URL rewrite feature.

There might be various implementations, but basically it's done by the web server taking the request path (e.g. /zuck/ or /popular/songs/whatever) and instead of looking for files in that path it parses it to parameters (there might be rules defined in HTTP stack or later on).

So http://www.facebook.com/zuck inside the server becomes an equivalent of http://www.facebook.com/profile.php?id=zuck (or something along those lines).

share|improve this answer

It's called nice-url's or URL-Rewrite.

You can traverse all requests to the index.php and there you can handle it by $_SERVER['REQUEST_URI'] in PHP.

You need to create a file, named .htaccess at the root of your site. This is the code what I'm using, it keeps images, icons and some other resources out of the scope:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !^/phpmyadmin/
    RewriteRule !\.(ico|gif|jp?g|png|pdf|doc?|xls?|ppt?)$ index.php [L]
share|improve this answer
