zro@rtv
07-25-2007, 10:58 PM
I was going to do this, but I thought I might be tangling up my logic, or overlooking something whether it be elegance or security... I was hoping someone could weigh in.
Is there any problem with doing something like this?
htaccess:
RewriteRule ^[a-zA-Z0-9/_-]+/?$ /index.php
index.php:
$uriArr = explode('/', $_SERVER['REQUEST_URI']);
include($uriArr[1].'php');
Is there something obviously bad about this?
It seems nice because then say 'domain.com/article/title' was requested,
index.php would include article.php, which then could contain code to query db for $uriArr[2]. And could use switch/case so if count($uriArr) < 2 then it could list 'articles'.And would be endlessly expandable.
One problem I can think of may be that it would be greedy?
As in if request URI was 'domain.com/article/non-existant/nonsense', if might not return a 404, if error checking wasn't robust?
What are the implications of not returning 404's when they should, and anything relevant to this method?
Is there any problem with doing something like this?
htaccess:
RewriteRule ^[a-zA-Z0-9/_-]+/?$ /index.php
index.php:
$uriArr = explode('/', $_SERVER['REQUEST_URI']);
include($uriArr[1].'php');
Is there something obviously bad about this?
It seems nice because then say 'domain.com/article/title' was requested,
index.php would include article.php, which then could contain code to query db for $uriArr[2]. And could use switch/case so if count($uriArr) < 2 then it could list 'articles'.And would be endlessly expandable.
One problem I can think of may be that it would be greedy?
As in if request URI was 'domain.com/article/non-existant/nonsense', if might not return a 404, if error checking wasn't robust?
What are the implications of not returning 404's when they should, and anything relevant to this method?