0

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.

2 Answers 2

2

you can add this in .htaccess for apache

RewriteEngine on 
RewriteRule ^se/(.*)$ $1

or this for nginx

rewrite ^/se/(.*)$ $1 last;
3
  • 1
    Shouldn't you add a / after the "se" to the nginx rewrite, to avoid urls begining with "se" from being redirected ? Like "/sea-products.html" would be redirected to "/a-products.html". The fix would be rewrite ^/se/(.*)$ $1 last;
    – Cladiuss
    Jun 20, 2023 at 14:22
  • right. thanks for the heads up
    – Marius
    Jun 20, 2023 at 14:28
  • Yes its correct but don't know why it was not working on our server, but worked with little different settings, anyway thanks for providing the solution
    – Sheri
    Jun 23, 2023 at 7:53
0

In my case it was worked with the following code on Apache

RewriteRule ^se$ https://website.com/ [R=301,L]

RewriteRule ^se/(.*)$ https://website.com/$1 [R=301,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.