I’m trying to rewrite some query strings I have in my URL like this :
foo.com/index.php?page=admin&view=news&action=edit&id=3
to
foo.com/admin/news/edit/3
But can’t figure it out…
it should also works if I only have the ‘page’ parameters for example, since I don’t always have these 4 parameters (page,view,action,id) in my urls, of course.
any suggestions?
The easiest way is to do most of the parsing in PHP code.
Use rewriterules like
And then access the request uri (
$_SERVER['REQUEST_URI']) from PHP, and parse it into as many parts as you want.