?
Solved

Sending 410 status code with redirect?

Posted on 2003-02-24
6
Medium Priority
?
1,819 Views
Last Modified: 2008-02-26
I have a 404.php file on my website to take care of my file not found errors. The default procedure (if not specified otherwise) is to forward the user to my main page AND I also want to send a 410 status code so that search engines that are following an incorrect URL don't think I'm cheating and using multiple doorways to point to my main page.

The problem ist that even if I send a 410 status code before...

header ("HTTP/1.0 410 Gone");

...the status code will automatically change to 302 as soon as I forward to a different page (as specified in the PHP manual: http://www.php.net/manual/en/function.header.php).

header("Location: http://www.mydomain.com/");

Does anybody know if there is a solution for this?

Thanks!
0
Comment
Question by:yosmc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:3gg
ID: 8010473
410 Gone shouldn't re-direct! If you want moved, you would want 301 or 302.
0
 

Author Comment

by:yosmc
ID: 8027753
Let me try again...

I am currently using the following two lines in my 404.php file:

header ("HTTP/1.0 410 Gone");
header("Location: http://www.mydomain.com/");

My problem is that the second line will overrule the first line. Instead of a 410 gone status code, it will send a 302 moved status code. However, I don't want to send a 302!

Hope that's clearer. :)
0
 
LVL 1

Expert Comment

by:3gg
ID: 8028360
Yes, your code is clear, however, to re-direct the browser you would need to use the 302 code instead. You might consider trying a meta re-direct instead, you will be able to keep your error code that way, but still accomplish the same effect.

0
Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

 

Author Comment

by:yosmc
ID: 8028465
The problem is that search engines HATE meta-redirects, and Google even gives penalties for them...
0
 

Author Comment

by:yosmc
ID: 9805575
In the meantime I was able to solve this problem. Basically, if a 404 file ends up sending a 302 header, it's a good idea to double- and triple-check if the file itself doesn't contain code that accidentially sends the header. (In my case, I had a META-tag somewhere that I deemed harmless - but after removing it, I finally got the 4xx header I desired.) Hope this helps someone.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 9806292
Question closed and points refunded

PashaMod
CS Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question