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
-
Reusing an already 301 redirected URL for a very important keyword
I have a question about reusing an already 301 redirected URL Till now I never reused an URLs that has been already redirected with a 301 redirect. However, I just started working on a website where in past they created a lot of 301 redirects without thinking about the future, and now certain URLs, that are currently redirected with a 301, would be very useful (exact match) and needed (for some of the most important keywords for this specific business), to maintain an optimal, homogeneous and "beautiful" URL structure. Has any of you ever reused a URL that was previously redirected with a 301 redirect? If yes what are your experiences with it? Can content on the reused URL (that was previously 301 redirected and than the redirect removed) normally rank if the page is reestablished and the redirect is removed (and you do great content, on page, internal linking, backlinking, .... ) or is such an URL risky / not recommended / "burned" forever and not recommended to be reused again... especially for very important keywords since it present the exact match ?! Thank you very much for all your help! Regards
Technical SEO | | moz46y0 -
Redirect 301 to homepage
Hello there, I have some low quality pages in my site, can I redirect 301 them to my homepage? My website is: https://idanito.com idanito.com
Technical SEO | | dannybaldwin0 -
301 redirection for e-commerce website
Hi moz community, I am the web agency for a e-commerce website. Its current domain is https://www.liquorland.co.nz but now all the e-commerce part will be moved to a sub-domain https://shop.liquorland.co.nz. There are thousands of e-commerce current being indexed in Google (i.e., 15,500) plus they also have a mobile version of the page like /mobile/default.aspx. Is it necessary to 301 redirect all the pages? We are afraid it may slow down the website because the request will go through thousands of filters. Is it OK to just redirect the main categories? Many thanks in advance.
Technical SEO | | russellbrown0 -
.htaccess Redirect 301 issues
I have completely rewritten my web site, adding structure to the file directories. Subsequently added was Redirect information within the .htaccess file. The following example ...
Technical SEO | | Cyberace
Redirect 301 /armaflex.html http://www.just-insulation.com/002-brands/armaflex.html
Returns this response in the URL bar of ...
http://www.just-insulation.com/002-brands/armaflex.html?file=armaflex
I am at a loss to understand why the suffix "?file=armaflex" is added The following code is inserted at the top of the file ...
RewriteEngine On redirect html pages to the root domain RewriteRule ^index.html$ / [NC,R,L] Force www. prefix in URLs and redirect non-www to www RewriteCond %{http_host} ^just-insulation.com [NC]
RewriteRule ^(.*)$ http://www.just-insulation.com/ [R=301,NC] Any advice would be most welcome.0 -
301 how?
My website is www.photosbykristopher.com, but I have some important links pointing to photosbykristopher.com How do I get my domain without the www to redirect to the domain with the www. PS I use Go daddy for hosting.
Technical SEO | | KristopherWho0 -
301 redirects
Hi, I am a working on a new web site, and I want to redirect all the urls of another site (on a different host) to this one. According to both hosts it is "impossible" to do this for all urls. I don't believe that to be the case, but how do I do this? And, should both sites be hosted on the same server first?
Technical SEO | | vibelingo0 -
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