·

photo credit: ????? ??? PC???????? ???????? Rewrite????????? via photopin (license)

How to programmatically create URL Rewrites in Magento Community

I already covered this topic before for Magento Enterprise, but of course: there are cases you need to import 301 redirects into Magento Community at some point. Here’s how to do this:

The method

The method to programmatically create (or import) 301 redirects into Magento Community is as follows:

Redirect to the homepage

If you need to redirect to the homepage, you can simply set the $toUrl  to index.php  or the URL identifier of your homepage. Setting it to ‘/’ wont work. I bumped into this one because a lot of 301 redirects redirected to the homepage, since the product in question no longer existed on the new website.

Visitors give this article an average rating of 3.6 out of 5.

How would you rate this article?

Leave a Reply