Menu

Re-routing to index
Handling all requests in a root file

Preface

Explanation

Basically, we're trying to push all the requests made to the server to a single root file, so a request made to /home.html will be directed to the root file of our choice....usually index.html

This complex sounding feature can be achieved by simply adding a .htaccess file to the root of our project directory.

The HTACCESS file

Code

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"

Code Explanation

RewriteEngine on enables RewriteEngine to rewrite URL patterns
RewriteCond %{REQUEST_FILENAME} !-d is a condition for a rquest re-route
RewriteCond %{REQUEST_FILENAME} !-f is a condition for a rquest re-route
RewriteRule . index.php [L] re-routes all requests to index.php

Next Steps

Basic Leaf app
Simple Routing
Request
Response