How to Redirect 301 Using Htaccess in Magento
Hey Google, page X is now page Y!
Ever needed to change the url structure in your Magento 1 or Magento 2 store? Probably, yes. Had you taken the time out to redirect those old URLs to the new ones? If not, now is the time to read this post and implement it in order to tell the users and search engines the latest address of your amazing content!
The .htaccess file or a Hypertext Access file is a configuration text file that controls directories and subdirectories and allows altering them. A permanent 301 redirection in your htaccess tells the search engines that an old link is replaced by the new one. It’s the recommended way to direct traffic from an existing page to the new one.
Why do you need to redirect 301 using htaccess in Magento?
- Changed the store altogether.
- Changed the URLs as a part of your efforts to improve SEO.
- Changes in the products you offer
- Simplified a URL or expanded it to include the details
- Correct a typo mistake in the URL
- Deleted a product attribute
Or any reason for which you want to the visitors and the search engines to be redirected to the new page!
Not ensuring to redirect 301 results in “404 – Page Not Found” error. This is the last thing you may want in your Magento stores.
Hence, make sure to redirect 301 using Htaccess in Magento stores with the method given below.
Method to Redirect 301 using Htaccess in Magento:
Locate the htaccess configuration file in the root on web servers running the Apache Web Server software and add:
Redirect 301 [old URL] [New URL]
Eg:
Redirect 301 /blog/create-quote-and-order-programmatically-in-magento-2/ /blog/create-quote-order-programmatically-in-magento-2/
Once you implement this method, the visitors and search engines will get redirected to your new URL.
Get rid of 404 errors in your Magento stores using redirect 301!
Any doubts with 301 redirects are welcomed in the comments section below.
Hopefully, the post helps! If so, do rate it with 5 stars.
Happy Redirects!
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
2 Comments
Hi,
I try to rewrite home page to a home language page with this metod but i don´t have the right anwerd, I use this in htaccess:
## Enable rewrites
Options +FollowSymLinks
RewriteEngine on
Redirect 301 https:// site com https:// site com/es/
Hello Jorge,
You need to follow the above example.
Thank You