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
-
How to Choose destination page for a 301 redirect?
I am doing some SEO for a wedding chapel in Vegas. There are some old packages that no longer exist and the bounce rate for the page is high so I am planning to 301 the page. How to best determine the best 301 destination? I have a few options. As an example the page was optimized for garden weddings. The page itself does not place well in the SERPS for garden weddings in Las Vegas, but our outdoor wedding packages in Las Vegas page places in the top 10. So that page is in an option. However, there is a different location that has a garden setting. Is that a better choice? Some content might match better than others, but any page I choose would be relevant content. Thank you so much 🙂
Technical SEO | | leslieevarts0 -
What coding works for SEO and what coding doesn't?
Hi: I recently learned about inline styles and that Google started penalizing sites for that in October. Then I was told that Wix and Flash don't work (or work well) either for SEO as the engines won't crawl them (I think). Does anyone know of a blog that goes over everything that doesn't work so that I could recognize it when I look at someone's code. Anyone know of such a resource? Cheers, Wes
Technical SEO | | wrconard0 -
Best Practice on 301 Redirect - Images
We have two sites that sell the same products. We have decided to retire one of the sites as we'd like to focus on one property. I know best practice is to redirect apples to apples, which in our case is easily done since the sites sold the same thing. www.SiteABC.com/ProductA can be redirected to www.SiteXYZ.com/ProductA. My question is how far does that thinking go regarding images? Each product has a main product page, of course, and then up to 6 images in some cases. Is it necessary to redirect www.SiteABC.com/ProductA-Image1.jpg to www.SiteXYZ.com/ProductA-Image1.jpg? Or can they all be redirected to just the product page?
Technical SEO | | Natitude0 -
I have altered a url as it was too long. Do I need to do a 301 redirect for the old url?
Crawl diagnostics has shown a url that is too long on one of our sites. I have altered it to make it shorter. Do I now need to do a 301 redirect from the old url? I have altered a url previously and the old url now goes to the home page - can't understand why. Anyone know what is best practice here? Thanks
Technical SEO | | kingwheelie0 -
301 redirect from Blogger
Hello, I have a client with a Wordpress network of blogs, each blog is owned by a different blogger. Many of them were migrated time ago from Blogger. I have seen that the way used to redirect them is a meta refresh, so no authority is being passed. I cannot find any reliable way of making a 301 from Blogger, There are some plugins, but I'm afraid of using them. Any of you have experience with this situation please? I have even thought about placing a global rel canonical before the meta refresh, but I think that here the problem is the meta refresh itself.... Thank you in advance
Technical SEO | | Juandbbam0 -
Need Help writing 301 redirects in .htaccess file
SEOmoz tool shows me 2 errors for duplicate content pages (www.abc.com and www.abc.com/index.html). I believe, the solution to this is writing 301 redirects I need two 301 redirects 1. abc.com to www.abc.com 2. /index.html to / (which is www.abc.com/index.html to www.abc.com) The code that I currently have is ................................................... RewriteEngine On
Technical SEO | | WebsiteEditor
RewriteCond %{HTTP_HOST} ^abc.com
RewriteRule (.*) http://www.abc.com/$1 [R=301,L] Redirect 301 http://www.abc.com/index.html http://www.abc.com ...................................................... but this does not redirect /index.html to abc.com. What is wrong here? Please help.0 -
301 Redirecting weird URLs with % in them
I've been working on redirecting links reported as 404 in Google webmaster tools. I've stumbled upon 41 URLs that Google is reporting as 404 that include a '%' in the URL, but I don't know how to redirect. Here is an example: URL: bond_information.htm%20Surety%20Bond%20Information,%20with%20FAQ Attempted redirect: redirect 301 /bond_information.htm%20Surety%20Bond%20Information,%20with%20FAQ http://www.mysite.com/ Unfortunately, after implementing the redirect, http://www.mysite.com/bond_information.htm%20Surety%20Bond%20Information,%20with%20FAQ still resolves a 404 error. Anyone successfully fix these errors using Apache .htaccess?
Technical SEO | | TheDude0 -
How many steps for a 301 redirect becomes a "bad thing"
OK, so I am not going to worry now about being a purist with the htaccess file, I can't seem to redirect the old pages without redirect errors (project is an old WordPress site to a redesigned WP site). And the new site has a new domain name; and none of the pages (except the blog posts) are the same. I installed the Simple 301 redirects plugin on old site and it's working (the Redirection plugin looks very promising too, but I got a warning it may not be compatible with the old non-supported theme and older v. of WP). Now my question using one of the redirect examples (and I need to know this for my client, who is an internet marketing consultant so this is going to be very important to them!): Using Redirect Checker, I see that http://creativemindsearchmarketing.com/blog --- 301 redirects to http://www.creativemindsearchmarketing.com/blog --- which then 301 redirects to final permanent location of http//www.cmsearchmarketing.com/blog How is Google going to perceive this 2-step process? And is there any way to get the "non-www-old-address" and also the "www-old-address" to both redirect to final permanent location without going through this 2-stepper? Any help is much appreciated. _Cindy
Technical SEO | | CeCeBar0