Hello all,
I’m building my first client website and I need to make redirects from the old URLs to the new ones.
Now I use this code in my .htaccess file:
[php]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
[/php]
Which allows me to route requests through bootstrap.php like this:
[php]
if ($_SERVER[‘REQUEST_URI’] === BASE_URL) {
$model = new Model\Page($db);
$controller = new Controller\Page($view,$model);
$controller->home();
} elseif ($_SERVER[‘REQUEST_URI’] === BASE_URL . ‘about’) {
$model = new Model\Page($db);
$controller = new Controller\Page($view,$model);
$controller->about();
}
[/php]
Now let’s say I want to redirect the old search page to the new search page, the old URL looks like this:
/categories/43/all-categories.htm?keywords=&all_categories=43&gender=
It’s pretty messy in my opinion, in the new site I’ve made it like this:
/categories?name=&category=all&gender=
However the problem I have is I don’t know how I can redirect requests from the old URL to the new page? I’ve never had to do it before and I’m not sure with the code in the .htaccess file if you can use it for redirects?
The only file on the server is index.php which includes bootstrap.php and after all the routing is done the view for each page is just included in the code depending on the URL.
Can anyone give me some advice on what I can do?
Thanks,
Adam