Update! Looking for instructions/more detail? I’ve posted a quick Magento 301 How-To
I’ve been working on cleaning up the IA on a Magento based eCommerce store and noticed something that may be of interest to anyone using the Magento’s URL Rewrite Management to create path-level permanent redirects….
Yeah, this is a minor detail (maybe), but why not make sure it’s done correctly …So what am I nitpicking here?
The Problem
Magento asks for an “ID Path” “Request Path” and “Target Path”
Trouble is…that the target path is treated as a target url when output to “location” in the response header. These redirects still work correctly in terms of functionality, but I’d rather see the full URL location in the response header instead of an absolute path. My entire point here, as ridiculous as it seems, is that I’m required to input only a path for “ID Path” and “Request Path” (full URLs don’t work here, making manual Mod_Rewrite wizardry necessary for host/domain level redirects), but “Target Path” should read “Target URL”
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 = ”;
//}