I’ve had a hard timing learning rewrite rules in .htaccess files, so I was hoping someone could show me how to rewrite this:
test.com/home/feed/toak/nyheter/vg
into this:
test.com/index.php?r=home&f=feed;toak;nyheter;vg
This is a dynamic URL, and can have multiple elements seperated by ; in the end. I want my users to be able to type in as human friendly URLs as possible. I’m hoping someone can help!
If you have variable number of parameters, you can’t do it only with .htaccess. You could rewrite in php:
And parse
$_SERVER['REQUEST_URI']in rewrite.php.For static number of 4 variables:
Or you could do (for any number of variables):
And use
$_GET['f'] = strtr($_GET['f'], '/', ';');in index.php.