-
Notifications
You must be signed in to change notification settings - Fork 0
ROUTING.md
Jason Brain edited this page Jan 10, 2026
·
1 revision
"Pretty URLs" turn ugly query strings (e.g., index.php?page=about) into clean, readable paths (e.g., /about). This improves SEO and user experience.
Core CMS uses an Apache .htaccess file to intercept all incoming requests.
-
Interception: The server checks if the requested file (e.g.,
assets/images/logo.png) actually exists on the disk. - Passthrough: If the file exists, the server delivers it directly.
-
Rewrite: If the file does not exist (e.g.,
/my-blog-post), the server internally redirects the request toindex.php.
RewriteEngine On
RewriteBase /
# If the request is not a real file or directory...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# ...send it to index.php
RewriteRule ^(.*)$ index.php [QSA,L]Once index.php receives the request, it acts as the "Front Controller."
-
Capture: We inspect
$_SERVER['REQUEST_URI']. -
Parse: We break the path into segments (e.g.,
/post/my-slug). -
Dispatch:
-
/admin-> Loads admin dashboard. -
/post/{slug}-> Queries the database for a post with that slug. -
/-> Loads the homepage.
-
- Ensure the
.htaccessfile exists in your root directory. - Visit a non-existent URL like
/testing-123. -
Success: If you see your Homepage (or whatever
index.phpoutputs), the routing is working. -
Failure: If you see a standard Apache/Browser "404 Not Found" page,
mod_rewriteis likely disabled or ignored.
-
404 Not Found:
- Ensure
mod_rewriteis enabled in Apache. - Ensure
AllowOverride Allis set in your Apache config (httpd.conf) for your web directory.
- Ensure
-
500 Internal Server Error: Usually a syntax error in
.htaccess. Check your server error logs. -
Subdirectories: If installed in a subfolder (e.g.,
example.com/cms/), you may need to changeRewriteBase /toRewriteBase /cms/. - Nginx/IIS: This guide assumes Apache. Other servers require different configuration files.