You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “Nitpicking Magento Custom URL Rewrite Management for 301 Redirects”.
You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “Nitpicking Magento Custom URL Rewrite Management for 301 Redirects”.
Hi — I found this post as I was trying to sort out what appears to be a similar issue.
When I select Catalog Rewrite Management and edit one of the system entries, id path, request path and target path seem … backwards. And they are not editable for some reason (I am an admin), even if I try to make a custom rewrite.
The problem is the “request path” has the key name, e.g. “energy-star”, and the id path has one form (category/47) while the target path has another (catalog/category/view/id/47). I read this as “when a request comes in with the name energy-star send it to catalog/category/view/id/47. This is fine, but if I enable 301 redirects, Magento does a 301 redirect from the clean URL to the catalog/category/view/id/47 URL. Same with products.
I want the opposite: since there are several cases where Magento displays the non-canonical form of a product or category URL, I want Magento to 301 redirect to the canonical (“clean”) form. But this doesn’t seem to be possible.
Am I missing something?
Thanks!
Tom
Tom – From what you’re describing, it sounds like you’ve changed the System rewrite for your category from the default “No” redirect to a “Permanent (301)” redirect. The following is making that assumption, let me know if I’m wrong!
Magento treats the target path for a rewrite as the resource to display at the URL requested by the browser– when a redirect is specified, the target path becomes the literal “Location” in the server response header (moved permanently to:), and is subsequently displayed as such in the browser.
A permanent redirect in Magento’s URL Rewrite Management should be created as a Custom Rewrite (with “Redirect: Permanent (301)” selected) separate from/in addition to the default (unedited) System non-redirecting rewrite.
Here’s where it gets totally un-intuitive:
1. Ignore Magento’s system/internal identification paths.
2. Use the path of the URL to be redirected for both “ID Path” and “Request Path” — the “Target Path” is the URL to redirect to.
I’m interested to know what you’re shooting for in your canonicalization efforts — Is it just the problem you described here (a request for energy-star.html returns “catalog/category/view/id/47″)? Wrestling with Magento’s built in duplicate content engine (one product page on the root and a duplicate for every category and subcategory)?
I ask because I’ve only had to redirect pages that I’ve renamed — and I think I’ll check out Yoast’s “Canonical URLs for Magento” extension (adds the link rel=”canonical” tag) for the duplicate content issues.
Thank you so much for posting this! you’re right this is completely un-intuitive, the line “2. Use the path of the URL to be redirected for both “ID Path” and “Request Path” — the “Target Path” is the URL to redirect to.” should be made bold
Thanks
THIS IS ONE SOLUTION:
Edit /app/code/core/Mage/Catalog/Model/Url.php
Find line 632 and change:
//if (null === $parentPath) {
//$parentPath = $this->getResource()->getCategoryParentPath($category);
//}
//elseif ($parentPath == ‘/’) {
$parentPath = ”;
//}