I was thinking about saving the whole index.php?article=3402 part as slug_old in the articles table.
And then checking not only the slug column but also the slug_old column if the parameter in the url corresponds to one of them.
Then depending on the result I am not sure, again, what to do next.
Should I:
somehow add the code 301 (moved permanently) to the header of the response? How to do that in the controller? When returning the view at the end or before?
or should I redirect first to the new link with the code 301 and then proceed as usual?
Or is this strategy not optimal and you would suggest something better?
@vedoj You could have a redirects table that maps the old article ids to the new ones.
Dependent on your setup (LAMP or LEMP) you could setup the old entry at /index.php to point to a specific route and on the controller responsible for that route then have a logic that handles verifying the received article Id and perform a 301 redirect.