Page 1 of 1
Redirect from old URL
Posted: Sat Jan 21, 2023 6:56 am
by mishanian
Hi, after upgrading from PHPMaker 2020 to 2023 I have an issue with changing the address URLs.
for example, login.php is changed to login, logout.php to logout and also index.php was added as favourite to the users' browsers.
what is the best way to redirect them from login.php to login incase if they click on the old URL?
Re: Redirect from old URL
Posted: Sat Jan 21, 2023 9:50 am
by arbei
Re: Redirect from old URL
Posted: Sat Jan 21, 2023 12:07 pm
by mishanian
Hi, thank you. the following code on Route_Action works for me:
$app->get('/login.php', function ($request, $response, $args) {
return $response->withRedirect("login");
});
$app->get('/logout.php', function ($request, $response, $args) {
return $response->withRedirect("logout");
});
$app->get('/home.php', function ($request, $response, $args) {
return $response->withRedirect("home");
});
Re: Redirect from old URL
Posted: Sat Jan 21, 2023 4:30 pm
by arbei
Although it might work for you, it is not quite correct to add "routes" like that. I suggest that you use .htaccess. If you don't want to customize the .htaccess, you may make an extension to add your rules to the .htaccess.