Help with 301 redirect code
-
Hi,
I can't work out how to make this one work and would apreciate if someone could help.
i have a series of folders from a old site that are in the structure:
/c/123456/bags.html (the "123456" changes and is any series of 6 digit numbers), and the "bags.html" changes depending on the product.
I need that to be 301 redirected to the following format:
/default/bags/bags.html -
Hi Paul,
As Andy mentioned earlier, the complexity here comes by the fact that these IDs cannot be simply removed since they play a role in the Magento product/category system.
The first step would be that you identify how these are generated to identify the best way to optimize it to become relevant or at least doesn't add more depth and complexity in the URL structure.
I've seen that there's a URL rewrite area in Magento with some system configuration options that you might want to take a look here and to this in-depth guide explaining Magento URL rewrites.
I've also seen that a similar question has been asked in Stackoverflow and as you can see the potential alternatives discussed here goes into Magento's system configuration.
Hope this helps!
Aleyda
-
no worries Andy, I really appreciate you trying
-
it would be hard to do without knowing the system really well, though that plugin maybe able to help. The reason is that if those codes change they could mean any category - the last bit is likely not an issue of product name as url, but the category bit isn't so easy - unless it can be ignored and pulled from the CMS - again not being a magento expert I don't know how this would be done. sorry.
-
Thanks Andy, i'll take a look.
I'm no htaccess guru, but was hoping that there was some sort of wildcard that could:
find "any product" (eg bags.html) in categories /c/123456/ and redirect to /default/bags/i just can't get my head around it. Is there a * or ? or combination? as it would need to pick up the changing 6 digits
-
oh erm sounds a little odd set up - maybe worth trying http://shop.ecomdev.org/url-rewrite-indexer.html
-
thanks guys.
Andy...
yes, i need the new format to be /default/category/bags.html (but the bags.html will vary with whatever the original product is).
The category has no relation to the new category. It was generated by a old cms system and seems to fluctuate.
Yes, it is a Magento shopping cartTom,
yes, it is .htaccess>
I have added some other 301 redirects successfully, but can't work out how to change the 6 digit category, while still making sure the end product (eg bags.html) redirects to bags.html in the new structure.I hope that makes sense?
Thanks
Paul -
Hi there
First of all, does your site use an .htaccess file? This is probably the most common solution used to implement 301 redirects. The SEOMoz guide to redirection is really useful in explaining how to implement redirects for apache servers and others.
These three generators can create the code for you, but it's very important to learn how the .htaccess file works before trying to implement it. Therefore, you should acquaint yourself fully with the Moz guide linked above.
Alternatively, if your site is running WordPress, you can setup 301 redirects very easily with the Yoast SEO plugin.
Hope these resources help.
-
ok this needs clarifying
so your old urls want to be of the format /default/category/bags.html yes?
does the category relate to the 6 digit number in some way?
Are you using a shopping care of some kind or is this a bespoke system?
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Consolidating 301 Redirects to Decrease Page Load Times - Major Concerns?
Hello, I am being pushed to consolidate our over 6k redirects that have accumulated over the course of 4 years. These redirects are one of the many factors causing extensive load times for our website. Many to most or over a year old, have not been used, or simply redirect back to the home page. Other than looking to keep the pages that have external links (also looking for recommendations/tools), are there other best practices from an SEO stand point to ensure there are no major hits to our website. A little more info, I am looking to pair 6K down by Removing all Redirects that have not been used Removing all redirects that are over 1 yr+ Remove all redirects that redirect to simply the home page or a smaller big bucket subfolder
Technical SEO | | Owner_Account
This should take the number from 6K to around 300. Are there any major concerns? Pat0 -
How to redirect 302 status to 301 status code using wordpress
I just ran the link opportunity option within site explorer and it shows that 31 pages are currently in a 302 status. Should I try to convert the 302's to 301's? And what is the easiest way to do this? I see several wordpress plugins that claim to do 301 redirects but I don't know which to choose. Any help would be greatly appreciated!
Technical SEO | | vmsolu0 -
Changing title tags, do we need 301 redirects
I found many duplicate title tags and I'm in the process of changing it Do I need 301 redirects in place when I switch it? I am only changing the title tag. Also, we are switching over to a new site very soon, I am worried that we might be using too many 301 redirect "hops" because we are doing a lot of optimization as well. (video from matt cutts describing 301 redirects and hops: http://www.youtube.com/watch?v=r1lVPrYoBkA. Does anyone have any experience in doing too many redirect hops that it affected your rankings? Any good ideas to avoid this?
Technical SEO | | EcomLkwd0 -
Site blocked by robots.txt and 301 redirected still in SERPs
I have a vanity URL domain that 301 redirects to my main site. That domain does have a robots.txt to disallow the entire site as well. However, for a branded enough search that vanity domain still shows up in SERPs and has the new Google message of: A description for this result is not available because of this site's robots.txt I get why the message is there - that's not my , my question is shouldn't a 301 redirect trump this domain showing in SERPs, ever? Client isn't happy about it showing at all. How can I get the vanity domain out of the SERPs? THANKS in advance!
Technical SEO | | VMLYRDiscoverability0 -
301 Redirect without specifying base domain?
Hi guys, about 10 minutes ago, I finally found the underlying problem in magento between 301 redirects and canonical tags - part of the reason why it was hard to identify was because the problem is not constant through all pages. Anyway now that I found the problem, I have about 50 301 redirects to implement via .htaccess. Now I know the regular syntax is Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html But I'm wondering if there's a way that the base domain doesn't have to be specified in the second half of this line. Something like: Redirect 301 /oldpage.html /newpage.html I'm sure this can be done, somehow. Thanks!
Technical SEO | | yacpro130 -
Setup 301 Redirects
I have been asked to transfer a clients old domain over to a new domain with a new site. All of the inbound links basically go to the homepage, and the few links that dont go to the homepage on the old site, might as well be redirected to the homepage on the new site. I'm wondering is there a "catch all" sort of redirect such as www.oldsite.com/* redirects to newsite.com. So any redirects we havent set up will automatically go to the new site homepage? And secondly, whats the easiest way to the redirects up? Can I just add it as a parked domain or addon domain in cpanel, and do the redirects in there? Or does it needs its own hosting for the old domain with its own htaccess file? Any help appreciated! 🙂
Technical SEO | | timscullin0 -
Is my 301 redirect working?
Very simple question here . I've redirected a bunch of older pages with decent ranking to some newer pages on my site, using the Thesis theme's built-in redirect function. However, in the SERPS, the older pages (and, importantly, older titles) still show up. When clicked on, they redirect to the new page, but it's still irritating because the older titles make the site look out of date. Is this Working As Intended, or have I or my theme done something wrong? And if it's the latter, what's the best way to achieve a redirect, preferably with a Wordpress plugin?
Technical SEO | | Cairmen0 -
Rel - canonical vs 301 redirect
I have multiple product pages on my site - what is better for rankings in your experiance? If I 301 the pages to 1 correct version of the product page - or if I rel caanonical to the one correct page?
Technical SEO | | DavidS-2820610