I’m using this to redirect to the home page if the post doesn’t exist:
if($_GET['id'] > mysql_num_rows($total_rows)){
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".site_url."/");
exit();
}
is this SEO friendly?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A 301 redirect is the wrong thing to do here. You should issue a 404 Not Found with a nice error page that explains the status to the user (including a link to your homepage or anywhere else) or similarly a 410 Gone if the content existed before. A 301 is incorrect here and may or may not be SEO friendly; a 4xx status is certainly more correct. Whether this status is issued through PHP or any other means is irrelevant.
Also see http://en.wikipedia.org/wiki/Http_status_codes