Zend certified PHP/Magento developer

Update on “Add Store Code to URLs” Setting and URL Redirection

Recently, I made the Magento settings update regarding the “Add Store Code to URLs.” I have set this option to “No,” which has successfully removed the store code from the URLs.

However, I have encountered a new issue. Customers are still able to access the old URLs, which now result in a 404 error. I would like to explore the possibility of redirecting these old URLs to the default URL instead.

Is there a way to implement automatic redirection for the old URLs? This would ensure a seamless transition for customers and prevent them from encountering 404 errors. I would greatly appreciate your guidance and assistance in resolving this matter.

Eg:-

https://website.com/se/website-silver.html should redirect to https://website.com/website-silver.html

Thank you for your attention to this issue. I look forward to your response.