.htaccess code
-
I've got a .htaccess file set up on a site to redirect specific old pages to specific new pages on a different site:
eg
Redirect 301 /oldpage.html https://www.newsite.co.uk/newpage.html
Redirect 301 /oldpage2.html https://www.newsite.co.uk/folder/
I have two questions:
1. Is that all the file needs? Or does it need any "rewrite engine on" type code?
2. I would also like to include code to "mop up" any other URLs and redirect them to the root, so that
/anyotherpage.html redirects to newsite.co.uk
Is there a way to do this?
-
What I'm looking to do is pass the link juice on from about 5,000 backlinks still pointing at our old site (which exists in domain form only a present) to the new site. Are these links pointed to the home page? Or are these pointed at relevant landing pages? If to the home page (and page is same on new site) nothing is needed. If these links are pointed to a landing page, you will need to route them to a related page on the new site and 301.
Are you saying there's not point in using a 301 if the page doesn't exist? Yes, no point unless there is a new landing page that is some-how related.
I don't really understand why you'd use a 301 if the page still existed...? If the page is on the new site and is the same url, no 301 is needed.
-
Thanks Kevin - I'm not sure I completely understand though.
What I'm looking to do is pass the link juice on from about 5,000 backlinks still pointing at our old site (which exists in domain form only a present) to the new site.
Are you saying there's not point in using a 301 if the page doesn't exist? I don't really understand why you'd use a 301 if the page still existed...?
-
Not really, since the resource doesn't exist anymore. If the resource exists (or something close to it) it would be a 301 and link juice will be passed (although not 100% of it).
If you have a relevant page, you should always 301 them. I would go through analytics and makes sure any "valuable" page has a relevant landing page. If no relevant landing page exists, you should 404 the result will eventually fall off.
I would also advise on creating a custom 404 page that explains what they are looking for and doesn't exist and show alternative pages/search bar. Users may get confused if they were looking for something specific and land at your home page.
-
Hi Kevin
Many thanks for this. Is a 404 as effective in passing on link juice as a 301?
-
2.) Are you talking about a catch-all? You can use 404 and redirect them to whatever. Try to redirect as much as possible though. Good luck!
ErrorDocument 404 /index.html
-
Thanks Andy, much appreciated. I'll look forward to the code
-
Your current redirects are fine and the best way is if its live to test it. Even thought I knew I had done it right recently when i went to https, I still do several random checks. They all came back as working - but no harm in testing.
Your point 2 is doable and as I am not on my laptop I don't have the code to hand. I will update in a few hours when back in the office for you, but your point 1 is correct.
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
-
301 redirect syntax for htaccess
I'm working on some htaccess redirects for a few stray pages and have come across a few different varieties of 301s that are confusing me a bit....Most sources suggest: Redirect 301 /pageA.html http://www.site.com/pageB.html or using some combination of: RewriteRule + RewriteCond + RegEx I've also found examples of: RedirectPermanent /pageA.html http://www.site.com/pageB.html I'm confused because our current htaccess file has quite a few (working) redirects that look like this: Redirect permanent /pageA.html http://www.site.com/pageB.html This syntax seems to work, but I'm yet to find another Redirect permanent in the wild, only examples of Redirect 301 or RedirectPermanent Is there any difference between these? Would I benefit at all from replacing Redirect permanent with Redirect 301?
Technical SEO | | SamKlep1 -
Redirection in .htaccess
Hi All, The problem is with the .htaccess file I have written 301 redirection code for Apache server but once I upload .htaccess file from ftp the website is throwing 500 error. Please help as I'm new to the redirection files.
Technical SEO | | Bharath_ATZ0 -
.htaccess yikes!
Hi guys, Having a bit of trouble getting a htaccess redirect working. It's very easy but I am making a small typo somewhere! I want to redirect about 400 product pages located at; http://domain.com/product/product-name to http://domain.com/product-name ..basically just dropping /product/ Any help would be appreciated as my errors in Moz are all over the place!
Technical SEO | | MrPenguin0 -
Content too buried in source code?
Our team is working on a refresh/redesign and am wondering if there's a quantifiable way of determining how high our meta data, H1 and paragraph should be in the source code. Or even whether I should be concerned with that. Our navigation will likely have dozens of links (we're going to keep it to under 100), and this doesn't even factor in the design elements. I am concerned about the content being buried. Are these the kind of concerns I should be having? Is there a measurable way to avoid it?
Technical SEO | | SSFCU0 -
Confirming Robots.txt code deep Directories
Just want to make sure I understand exactly what I am doing If I place this in my Robots.txt Disallow: /root/this/that By doing this I want to make sure that I am ONLY blocking the directory /that/ and anything in front of that. I want to make sure that /root/this/ still stays in the index, its just the that directory I want gone. Am I correct in understanding this?
Technical SEO | | cbielich0 -
Help with this metadata code!
My website developer used the code below for my metadata but SEomoz is showing an error for my metadata. How can I change with this code so it will work?
Technical SEO | | CapitolShine0 -
Broken links shall i put them in my htaccess file to generate juice
Hi, when i had to rebuild my website after my hosting company made an error, i lost over 10,000 pages and lost many thousands of links coming to my site. What i want to know is, instead of trying to recreate those pages again which would take me a long time, should i put them into my htacess file and have them point back into my site. so for example, if i have a link coming to my site to an article which could be, holidays in benidorm are not selling well, would it be a good idea to have that link pointed at the main benidorm section which is benidorm news. And if i had an article which was people are finding it hard to lose weight, instead of writing a new article could i have the link pointing to my health section? If this is the correct way of doing it to grab back some link juice, would it slow my site down and how many links could i put in my htacess file. So what i am trying to say is, if i put in say 1000 redirects into my htaccess file, would it slow my site down and is this a wise thing to do or should i just let the links go.
Technical SEO | | ClaireH-1848860 -
Should WordPress themes be hard coded for better SEO?
In the interests of making my site faster I have recently come across the suggestion of removing unwanted PHP from my WooThemes WordPress theme. The suggestion is to hard code the choices I have made in the WordPress template to reduce on database calls. Has anyone actually done this to their WordPress theme before and seen any measurable results?
Technical SEO | | Wallander1