Yes, that's exactly what mod_rewrite does.
But might I suggest adding a front controller so that you can add more logic in the future if necessary? Say you want to handle pagename.rss in the future to call a different controller that generates RSS feeds.
Rewrite all requests that aren't to actual files to index.php (or any name), and index.php looks at the REQUEST_URI and includes system/applicaton/controllers/pagename.php
Rewrite rule:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
basic index.php:
PHP Code:
<?php
$pagename = substr($_SERVER['REQUEST_URI'], 1, strlen($_SERVER['REQUEST_URI']) -
5);
include("system/application/controllers/" . $pagename . ".php");
The URL in the address bar remains pagename.php
Bookmarks