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
-
Redirection chain and Javascript Redirect
Hi, A redirection chain is usually defined as a page redirecting to another page which itself is another redirection. URL1 ---(301/302)---> URL2 ---(301/302)---> URL3 But what about Javascript redirect? They seem to be a different beast: URL1 ---(301/302)---> URL2 ---(200 then Javascript redirect)---> URL3 From what I know if the javascript redirect is instant Google counts it as a 301 permanent redirection, but I'm still not sure about if this counts as a redirection chain. Most of the tools (such as moz) only see the first redirection. So is that scenario a redirection chain or no?
Technical SEO | | LouisPortier0 -
301 Redirects
Looking for the best way to do the following. Business has changed its name, and has also become a corporate store. The old domain name is now no longer needed as a website page has been created inside the main corporate site. Obviously i dont want to loose all the traffic that we had and want to redirect them but there is a problem, that im unable to redirect the old domain to the new one due to office 365 installed on the hosting platform, and the old emails will need to run for another 6 months. I can remove the old site and put a landing page up, but i still need to redirect all the pages to the new site, and there is approx 50+ of them. My main question is i currently have atleast 50+ redirects already in there due to seo changes over the years, some would go back atleast 5 years, whats a safe amount of time that i can remove the older redirects And am i going about this the right way so i dont loose all the hard work on rankings etc
Technical SEO | | Dunjoko0 -
Help Setting Up 301 Redirects from Coldfusion Site to Wordpress Site.
I have created a new website and need to redirect all of the previous pages to the new one. The old website was built in coldfusion and the new site is built in wordpress. One of the pages I'm trying to redirect is www.norriseal.com/products.cfm to http://norrisealwellmark.com/products/. This is what I have in my .htaccess file <ifmodule mod_rewrite.c="">Options +FollowSymlinks
Technical SEO | | MarketHubb
RewriteEngine On
RewriteBase /
Redirect 301 /products.cfm http://norrisealwellmark.com/products/</ifmodule> The result of this redirect is http://norrisealwellmark.com/products.cfm How do I prevent the .cfm from appending to the destination URL?1 -
.aspx 301 redirects on Business Catalyst
Hi I am have moved my website from .aspx to business catalyst. I have found out (when the site already migrated!) that Business Catalyst does not support .aspx 301 redirects. On a previous post from 2012 (https://moz.com/community/q/aspx-files-will-simply-not-work-as-redirects) , someone has recommended a java script re direct. I have tried this but google search console is classing this as a 404 resulting in no link juice and my website dropping pages on google. I have tried to do 301 redirects at my server level but wont work. Anyone know a solution? Thanks in advance Keith
Technical SEO | | EntertainmentIdeas0 -
Virtual inlcude v.s. Redirect 301
Hi there, I manage a website which use a lot virtual includes ( SSI) because it caused a lot of duplicate content i introduced the Canonical url tag. But i still see bad rankings on some pages who are the leading of the virtual includes. Now i'am wondering is it better to remove all the virtual include pages ( url's) and make a redirect 301 of it. Does anybody know that is better for ranking the head page?
Technical SEO | | JoostBruining0 -
Is 301 redirecting all old URLS after a new site redesign to the root domain bad for SEO?
After a new site redesign ...would it hinder our rankings if we 301 redirected all old URLS that are returning 404 error codes to the root domain (home page) ? Would this be a good temporary solution until we are able to redirect the pages to the appropriate corresponding page? Thanks so much!
Technical SEO | | DCochrane0 -
301 redirecting a mobile site.
Is it possible to selectively 301 redirect mobile/tablet user agents and google robots from the desktop version of a website to a mobile site? Would this preserve the SEO for the desktop website while optimizing the mobile/tablet site for mobile SEO?
Technical SEO | | inc.com0 -
How should 301 redirects affect Page Authority?
We recently setting up 301 redirects from one of our sites so that the site redirects from the www version to the non-www version for all pages. We want to quantify what we expect to see as results. From what the experts say, we'd expect that the Page Authority of the canonical versio (non-www) will be higher than either of the two separate ones were previously. For instance, if this page - www.website.com/information/ - had a PA of 57 and this one - website.com/information/ - had a PA of 53, some time after the 301 redirects from www to non-www have been put into place, we should see the non-www version of that page move up to some PA about 57. It our thinking correct? How long does it normally take to see a PA update take place in a scenario like this? Thanks, Richard
Technical SEO | | LDS-SEO0