Just thought I'd throw this out there... but you may find it simpler to use a front controller pattern. The idea is you rewrite all URLs to one PHP script that serves as the entry point, then that PHP script examines the URL to decide what actions to take.
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ front-controller.php [QSA,L]
PHP Code:
// front-controller.php
$uri = $_SERVER['REQUEST_URI'];
if ($uri == '') {
require 'index.php';
} elseif ($uri == '/articles') {
require 'article_list.php';
} elseif (preg_match('#/articles/([\w\-]+)#', $uri, $matches)) {
$slug = $matches[1];
require 'article_show.php';
} else {
require '404.php';
}
Bookmarks