Redirect from old URL

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mishanian
User
Posts: 123

Redirect from old URL

Post 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?


arbei
User
Posts: 9355

Post by arbei »

Assume you use Apache, you may read Redirecting and Remapping with mod_rewrite.


mishanian
User
Posts: 123

Post 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");
    });

arbei
User
Posts: 9355

Post 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.


Post Reply