 <p>This is something that's usually done through the web server, so the answer depends on whether you're using Apache, Nginx, or something else. Here's how I do it with Nginx.</p> <p>I typically have a directory in my site root called <code>controllers</code>. All of the files in <code>controllers</code> correspond to URL paths. For example:</p> <pre><code>/controllers/home.php ---&gt; http://example.com/home /controllers/about.php ---&gt; http://example.com/about /controllers/contact.php ---&gt; http://example.com/contact </code></pre> <p>Then I use the web server (Nginx) to direct the traffic (which is what it's built to do). So if Nginx gets a request for <code>http://example.com/home</code>, then it looks in the <code>controllers</code> directory for a file called <code>home.php</code>. If the file exists, then Nginx serves it up. If the file doesn't exist, then Nginx serves up some fallback page. Here's what the Nginx configuration looks like:</p> <pre><code>server { listen 80; server_name example.com; root /srv/example; index index.php; rewrite ^/(.*)/$ /$1 permanent; location / { try_files $uri $uri/ /controllers$uri.php?$args; location ~ \.php$ { try_files $uri /index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } } } </code></pre>