..oO(k3pp0)
>Another way would be to redirect all requests to the index.php and let
the script parse the request URL. This is what I do in my own framework,
because it makes it a lot easier for me to add new functions or modules
to a website without having to modify any rewrite rule in the .htaccess.
Thanks!
How do you do that ("redirect all requests to the index.php and let
the script parse the request URL")?
I also do it with mod_rewrite with some additional rules:
RewriteEngine On
RewriteBase /
# remove leading www. from hostname
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule (.*) http://%1/$1 [R=301,L]
# exclude static URIs from rewriting
RewriteRule ^(css|download|images|scripts)(/|$) - [L]
# redirect internally to application script
RewriteRule .* index.php [QSA]
The last rule will internally redirect all requests to my front
controller. Internally means that this only happens inside the web
server, it won't send a redirect back to the browser, so the browser's
address bar won't be affected.
The script then just takes a look at $_SERVER['REQUEST_URI']. If the
requested URI starts with "/user" for example, it would call a method to
handle such a user request, "/admin" would trigger another method for
handling an administration request and so on. It's more flexible than a
pure mod_rewrite solution, but also more complicated, though.
Micha