We've encountered a problem where we have unwanted permanent redirects on a Magento store we're working on, and I'm looking to see how we can start with a blank slate in terms of these redirects. We do not need any since it's a developing site, and we wouldn't want anything redirected within this domain, either. The store is not live, and the following is what happened.
We didn't know about the URL Rewrite Management option under System -> Config -> Catalog -> SEO, so it was marked as "Yes" for "Create permanent redirects..." Some products were uploaded via a feed, but they were uploaded incorrectly. So, we re-uploaded them to over write. The result was that "White Shirt A" has its URL key as "white-shirt-a.html" in the admin or exported data feed, but the actual link that bring up the product is "white-shirt-a-1.html." If we go to "white-shirt-a.html," it gives us a 404 Not Found.
How do we clear all these permanent redirects? We've tried disabling or deleting these specific request path and target path entries under Catalog -> URL Rewrite Mangement, but they don't have any effect.
If your store is not live yet, follow this:
Empty/Truncate core_url_rewrite
table from Database.
Disable Permanent Redirects from Magento Backend.
Reindex Catalog URL Rewrites and all your URL's will be corrected.
In order to remove all permanent redirects you can:
1) Execute direct query (not recommended):
DELETE FROM core_url_rewrite WHERE options IS NOT NULL AND is_system = 0
2) Do it more gently:
$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 Custom Product Urls extension which enables you to clear all permanent redirects from admin panel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With