URL Rewrite question

Status
Not open for further replies.


I usually use this in .htaccess:

Code:
RewriteEngine On
RewriteRule ^/*([^/]+/+)*([^.]*[^/])$ http://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css|pdf)$ index.php [L,QSA]

and then parse $_SERVER['REQUEST_URI']
 
It depends on your application's design - how it translates an URL to a module/function, its URL mapping technique etc. Basically, I get the incoming request (for example /myapp/news/archive/3/) and parse it - it tells me that i need to get a module called "news", call method "archive" with parameter "3" (in the human language, "Display archive of news, page 3"). When combined with regular expressions for URL mapping, its very powerful and flexible - you can basically map *any* URL to *any* module/function in your application. It's also quite helpful for SEO - you can have a list of "pages", for every page you will have its URL scheme (regex), title, heading, meta description, meta keywords, it's template, which module does render it etc etc. Whats not in this list, throws a 404 page and so on.
 
Status
Not open for further replies.