301 redirect to index on dropped domains

guerilla

All we do is win
Aug 18, 2007
11,426
428
0
No
I'm picking up some dropped domains. I want to 301 incoming link juice from old deep links to my domain root.

Anything I need to worry about when putting this in htaccess? Is there an easy (or correct) way to 301 a 404 error?

TIA.
 


Just make sure that you are displaying the correct headers. I'm not to good with .htaccess at this point so i'm not sure on the syntax (i use php to 301), but there are utils online to check and make sure the correct headers are being sent. Search for "check 301 redirects". If done correctly the 404 header will never be sent.
 
Do you know what pages are being requested (that cause the 404s)?
No. To expand, I am picking up some dropped domains, that have backlinks to deep pages.

When I put these domains back up, I am installing new software on them, but rather than wasting the incoming links to 404s, I would like to redirect them (and the juice) to the index.

@jimmy1, thanks. That's sorta what I am talking about.
 
.htaccess

Code:
ErrorDocument 404 http://www.mydomain.com/optional-path-to-page.php

Like so?

Edit - this should result in a 200 OK response if you write the full hxxp:// path, rather than the relative file (e.g. /index.php). I believe that's what you want. You could check the server response using e.g. the Firefox plugin Live HTTP Headers, just to make sure.
 
^^ That will of course, still give the 404 header to ze bots, which may or may not be what you want (I'm guessing not).

You want to keep the goodness of the backlinks and bounce it to root so do you want to just 301 all the 404's to root? (Without showing a 404 header)

Be aware that if using something like WordPress it handles much of this in php, so you may need to code something up.
 
  • Like
Reactions: guerilla
^^ that's exactly what I meant: when you write out the full url instead of just the relative file in the code above, it *should* return the 200 header instead of the 404 header. Or so I thought. Is that not so?

In the case of Wordpress, it would be quite easy to do actually, with a php redirect like spamhat said. guerilla, are you using WP?
 
A 200 status code won't work here anyways. I'm pretty sure if the destination is different from the url entered a 302 header is sent by default and the 302 header won't work either. The 301 indicates permanent redirect and when the SE's encounter this header they know to push the link juice from the old page to the destination.
 
^^ good point. What about this setup then:

.htaccess
Code:
ErrorDocument 404 /404.php

404.php
Code:
<?php 
header ('HTTP/1.1 301 Moved Permanently');
header('location: http://mydomain.com/index.php');
 
if you're using wordpress, check out the 404.php page of your theme..edit that to do whatever you want (in this case, 301 redirect to root)
 
Holy shit, this thread has gone on way to long with out a solid answer.. it is something like this

RewriteRule ^(.*)$ hxxp://newsite.com [L,R=301]




That should do it in htaccess. If i understand correctly all he needs is an htaccess redirect because he doesn't have the content for the old sites, he just wants to push the link juice to new domain.
 
  • Like
Reactions: guerilla
^^ Yeah but I don't think he wants EVERYTHING going to the root, just everything that would be a 404.