404 On A Normal Page

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

404 On A Normal Page

Amezis
Well, I am using a mod_rewrite script, making "http://www.mysite.com/notfound/" a valid page even if it shows that the page could not be found. How can I add to the header with PHP that the page is not found, replacing the 200 status code (OK)?

Reply

gameratheart
QUOTE(Amezis @ Sep 9 2006, 08:32 PM) *
Well, I am using a mod_rewrite script, making "http://www.mysite.com/notfound/" a valid page even if it shows that the page could not be found. How can I add to the header with PHP that the page is not found, replacing the 200 status code (OK)?


I am not too sure what you mean here. Do you mean that you want to make it so that if a 404 appears on your website, it still thinks the page exists?

Reply

Amezis
No:
CODE

<?php
if ( page_exists )
{
      // Do all normal stuff
}
else
{
      /* Page doesn't exist, send a 404 error status in the header instead of the 200 status, and give the user a friendly 404 error page (I do not wish to use a redirect) */
}
?>

Reply

farsiscript
Dear Amezis You can customize erre page in cpanel You can manage HTML code and then copy soruce of your design and save file
erre pages save as shtml files


Reply

Spectre
But that's not what he wants to do.

Simply use the header() function within a script to overwrite the original status and send a 404 message:

CODE
header('HTTP/1.1 404 Not Found',true);

Reply

electron
Hey what do you want to do ?
Do you want to use mod_rewrite in apache and make a not found page having the URL http://www.mysite.com/notfound/

Or do you want to send a header that the page wasnt found.
Please Clearify

Reply

Spectre
He has clarified, in his previous post. He wants scripts to be able to send a 404 Not Found message after processing the request.

Reply

Amezis
Thanks Spectre. smile.gif

For those who didn't understand my question, I have a php file. If someone loads file.php?view=this_exists, everything is done normally. But if someone loads file.php?view=this_doesnt_exist, then the 404 error code is shown. I am using mod_rewrite, so file.php?view=this_exists is displayed as /this_exists.

A search engine would not understand that /this_doesnt_exist doesn't exist unless the 404 header was sent. So I simply wanted to send a 404 in the header without using the apache error function since that wouldn't do the job.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. response code 404/normal - 836.86 hr back. (1)
Similar Topics

Keywords : 404 normal


    Looking for 404, normal, page

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for 404, normal, page

*MORE FROM TRAP17.COM*
advertisement



404 On A Normal Page



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE