URL Rewriting
Basically, we're trying to push all the requests made to the server to a single root file, so a request made to /home.php
will be directed to the root file of our choice....usually index.php
.
This complex sounding feature can be achieved by adding a web server configuration depending on your server of choice.
Apache - .htaccess
This is a basic example of an htaccess file. It basically re-routes all requests to our index.php file.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
Save as .htaccess
in your the same directory as your "root file"
Nginx - nginx.conf
A basic example with nginx web server
try_files $uri /index.php;
You can read below for an overview of url rewriting.