Magento: how to remove all persistent redirects

We are faced with a problem when we have unwanted permanent redirects in the Magento store that we are working on, and I see how we can start from scratch in terms of these redirects. We do not need them, since this is a developing site, and we do not want to redirect anything in this domain. The store is not alive, and that's what happened.

We did not know about URL management in System → Config → Catalog → SEO, so it was marked “Yes” for “Create permanent redirects ...” Some products were downloaded through the feed, but they were not loaded correctly. So, we reloaded them to write. As a result, White Shirt A has its own URL in the form of white-shirt-a.html in the admin panel or exported data feed, but the actual link that invokes the product is white-shirt-a-1. HTML ". If we go to" white-shirt-a.html ", this will give us 404 Not Found.

How do we clear all these persistent redirects? We tried to disable or delete these specific request paths and target path entries in the Catalog → URL Rewrite Mangement section, but they have no effect.

+5
source share
3 answers

If your store is not already alive, follow these steps:

  • Empty / truncate core_url_rewritetable from database.

  • Disable persistent redirects from the Magento Backend.

  • The URL of the Reindex Rewrites directory and your entire URL will be fixed.

+10
source

I cannot guarantee that it is safe. But for now, it worked.

I ran this query:

"REMOVE * FROM core_url_rewriteWHERE is_system! = 1";

This request deleted all user rewriting rules, of which we had something like 500,000. Most of them were created when someone turned off the ".html" extension in Search Engine Optimization without changing "Create rewriting rules when changing URLs "to no."

0
source

, :

1) ( ):

DELETE FROM core_url_rewrite WHERE options IS NOT NULL AND is_system = 0

2) :

$write = Mage::getSingleton('core/resource')->getConnection('core_write');
try {
    $write->beginTransaction();
    $table = Mage::getSingleton('core/resource')->getTableName('core/url_rewrite');
    $count = $write->exec('DELETE FROM ' . $table . ' WHERE options IS NOT NULL AND is_system = 0');
    $write->commit();
    $this->_getSession()->addSuccess($this->__('Successfully removed %s redirects.', $count));
} catch(Exception $e) {
    $write->rollback();
    $this->_getSession()->addException($this->__("An error occurred while clearing url redirects: %s", $e->getMessage()));            
}

3) Or you can install the Custom Products Extension , which allows you to clear all permanent redirects from the admin panel.

0
source

All Articles