Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Redirect To 404.html Using Header()


we need to redirect to a custom 404 page in PHP source code.

For example, a page URL is htt p://www.site.com/info.php?id=123

When the DB query for id=123 returns nothing, I will redirect user to a custom 404 page, by using the following method:

header("Location: /404.html");
However, according to Server Header Check, I just sent a 302 header and tell google that the content of www.site.com/info.php?id=123 is temporary moved to www.site.com/404.html (and please come back later). Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Header Redirect Bug
I have a problem doing a permanent redirect. It works only if I
directly send the new location header (third line in sample below) but
never in combination with sending a "301 Moved permanently" first
(second line below). Unfortunately my server is shielding error
messages from me (and I don't have access to the PHP.INI).

------- Sample -------
<?
header("HTTP/1.1 301 Moved permanently");
header("Location: http://www.example.com");
?>
----------------------

(Note: there is no space anywhere or anything else before I send the
header. Also: I cannot send the "Moved permanently" on its own either.
It always breaks my script, but I don't know why.)

What can I do? If I redirect without 301 I'm afraid Google won't change
it's index of my pages.

View Replies !
Can't Get Header() To Redirect
If I create a page named redirect.php and it's only content is:
<?php
header("Location: http://www.google.com");
?>
Should it not redirect to www.google.com? I can't get the header()
function to redirect.

I'm trying to take an online reservation... the customer fills out
contact and billing info at SignUp.php. The form on SignUp.php
submits to Confirm.php, where I perform validation.

If the input fails validation, I want to redirect back to SignUp.php.
Otherwise I will display the input for confirmation before processing
the order. Maybe I'm implementing this wrong... using asp thinking
for a php implementation, but I think this should be simple and I must
be missing something.

View Replies !
Redirect After With Out Using Header
Is there a way to redirect a page after the header has already been sent?

View Replies !
No Redirect With Header()
I am working on a redirect script to log "out"'s. I was trying to do it with a header redirect:

<?php

// Log in database
/*
-snip-
*/

// Send user away
header ("Location: ".$url);
?>

Does this seem like it should work? It doesn't. What is the correct syntax for these things?

View Replies !
Header Redirect
I recently switched my site to a new design using mod_rewrite so my pages are no longer products.php?product_id=99, instead they are now products/widget/index.html. I was curious how I could use a 301 redirect to show Search Engines that it was a permanent move.

I have the old page products.php that just grabs the id and gets the sku of the product (in the case above it was "widget") and then uses a PHP Header Redirect to send them to the new page. I was curious if it is possible I can add the 301 code to the PHP Header Redirect?

View Replies !
Redirect Using Header()
Using this code, when i provide incorrect username and password, it should redirect me to a separate login page. unfortunately, instead of redirecting me, it gives me the following error: Code:

View Replies !
Header Redirect With GET Variables
I have PHP 5.2.2 installed on my WinXP machine. I am using the web server built into Proxy Plus, with PHP enabled using php-cgi.exe. It seem to be working fine, but I have a problem trying to redirect to a new page using the header() function.

When I do:
header('Location: mypage.php?var=fred');

The browser (Firefox 2.0.0.3) get redirected and shows the following in the location bar:
http://localhost/mypage.php?var:%20fred

Notice that the "=" gets changed to ":%20"

Of course this is not working. I have tried everything I can think of, including using %3d instead of =. Nothing seems to work. Any ideas? Could this be a problem with PHP, or a problem with the web server in Proxy Plus, or something else? I have NOT tried this on any other web server.

View Replies !
Header And Redirect Problem.
i have two php pages, the first one displays a list of records and the second is an admin page of the selected record from the first page. In my admin page, i have a "Back to list" button that executes this Code:

header("Location: hr.php?pi=$pi&s=$sort&o=$order");

everything worked fine until i added this to the first page:
Code: session_start();
if (!isset($_SESSION["test"]))
session_register("test");
$_SESSION["test"] = "hello";

and this to the adin page
Code: session_start();
echo($_SESSION["test"]);

so I get this when I try to redirect to the listing page:

Warning: Cannot add header information - headers already sent by (output started at c:program fileseasyphpwwwintranetcommoncommon.php:247) in c:program fileseasyphpwwwintranethradmin_hr.php on line 99

and line 99 is header("Location: hr.php?pi=$pi&s=$sort&o=$order");

View Replies !
Header Location And Redirect
From my record insertion page I do, in some cases, this:

header("Location: http://$SERVER_NAME/mainpage.php?SID");

problem is that the mainpage.php doesn't takes new datas. I've to refresh
the page to see the new inserted record.

doing this:
header("Refresh: 0; URL=http://".$_SERVER['HTTP_HOST']."/mainpage.php?SID);

isn't considered a good alternative.
I want to redirect to the mainpage.php with refreshed datas.

How to do so ? may I keep Refresh header command or it will not work on some
browser ?

View Replies !
Setcookie And Header Redirect
I am trying to set a cookie once someone has logged into a site and then redirect them to another PHP page in the same directory. Below is my code: PHP Code:

View Replies !
Header() To Redirect A Page
I know that you can use header() to redirect a page, but that you have to use it before any script executes; How do you redirect the page after the script executes?

View Replies !
Header Redirect Problem
I have a "Go Back" form button in a script that I want to redirect the user back to the index page in most cases, but to a different page if they came from that different page.  I've tried using $_SERVER[HTTP_REFERER] and checking for the values passed by $_GET (inventory categories/database table names), and neither method works.  Instead, I always get redirected back to the index page. My code:

View Replies !
Redirect- Header.Location
how do I redirect from one page to another in PHP? I am novice, so keep it simple please.for example

  if(a>b)
      {
           header.Location("http://a.html"); }
  else
       {
            header.Location("http://b.html"); }

Is this right code?

View Replies !
Session And Header Redirect
Here is the code for the top of the "customise.php" page.

<?php require_once('../Connections/DM_database.php'); ?>
<?php include_once("../includes/functions.php"); ?>
<?php 
if (isset($_GET["Product_ID"])) { $ProductID = $_GET["Product_ID"];
} elseif (isset($_POST["Product_ID"])) { $ProductID = $_POST["Product_ID"]; $_GET["Product_ID"] = $ProductID;
} else { $_GET["Product_ID"] = "1"; $ProductID = $_GET["Product_ID"]; 

?>

............

View Replies !
Problems With Header Redirect
I am having problems with Header redirects on our site, I am using the following code to
Code:

View Replies !
Header Redirect Not Working
I am attempting to build a simple blog script into my webpage, everything is working fine, except, that the page will not redirect after it finished processing. I'm using header to redirect; however, I am not sending any output prior to the call, nor am I getting any sort of usefull error message.

The code is below. If anyone has any ideas I'd be glad to hear them, or if you have a better method for redirecting the user (similar to the way this board does it after a new post), that would also rock. BTW, I know that the whole file may not be relevent to the problem I am facing right now, but perhaps there is some output being sent and I am not seeing it, or any error related to it. Code:

View Replies !
Header Permanent Redirect
When doing a permanent redirect should I do the following or should the header replacement be true?

header('HTTP/1.1 301 Moved Permanently', true, 301);
header('Location: /new_location.php', false);

I am concerned about how Google and other search engines will see the new page it is redirected to. Will the search engine see "new_location.php" as the new location for the document and consequently update its index with the new URL...or will it think that "new_location.php" is nothing more than an error response document?

View Replies !
Redirect To Another Page Without Using Header()?
I've seen a lot of PHP redirect using headers. However, is there a way to redirect to another page without using header()? I have already outputted an html and did a validation using PHP. So, how can I redirect after the HTML page has been sent, say after 30 seconds after they've read that the registration is successful? Much like the way the Refresh works after a successful posting in WebmasterWorld.

View Replies !
Non Header Page Redirect
I want to do a page redirect but without using:

header("Location: http://somesite.com");

as it needs to be done at the end of a page after other code has been run... is there an equivalent to the ASP response.redirect?

View Replies !
Header Redirect From 404 Page
Due to a change of supplier I have to remove around 900 pages from my site all from within a sub-directory. These pages are all doing okay in the search engines so I'd like to be able to handle visitors who click on these pages in the serps.

My plan is to use my custom 404 page to redirect requests for pages in this sub-directory to the root page of this section using header("Location: index.php"). Would this cause any problems with the search engine spiders? I don't want the spiders being redirected as I want them to drop the old pages asap. Would a javascript redirect be a better option?

View Replies !
Post Variables From Header Redirect
I'm using header to redirect the browser to another page and in the url I've added ?var1=value1&var2=value2 to pass some argument as get to that script, can I pass in some way, arguments as post in this case ? may I do it in both methos at the same time ?

View Replies !
Redirect The Other Window With Header Function
I've got a small problem. On my site there's a news section (window 1) and people can react to the news. A small window (windows 2) with a form will popup. After submitting the form I want to close the small window and refresh the NewsWindow (window 1) contents.

View Replies !
What Do Spiders See On Header( Location ) Redirect
If I use:

<?
Header( "Location: http://www.example.com/1.php?id=12345" );
?>

as a way to redirect from
http://www.example.com/spider-friendly-address

What will the Spider see?
Will this approach help in SEO?

View Replies !
Cookies Not Working With Header() Redirect
I'm using the cookie to store the user's session ID. After they login, they are redirected to the page (index.php) they are supposed to hit after logging in. Index.php checks to make sure that everything is in order and if there isn't a cookie with the right info it will dump them back to the login page.

The problem comes after the user logs in...like I said, they are redirected after logging in; however, when I do this, index.php does not recognize that there was a cookie set. If I take out the redirect header() from the login page and just supply a link to index.php that the user must click after they login, everything works. From the php manual: Cookies will not become visible until the next loading of a page that the cookie should be visible for...A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.

I think that this might be part of the problem, and that somehow the header() isn't being recognized as an actual "page load." Just for the record cause I know someone will proly ask, I have called print_r($_COOKIE);to see if the cookie is set and it is.

View Replies !
Header Error Using Redirect Scripts
I'm working on a site for a racquetball goods company where sponsored players can sign in each year using a unique player number. Before they can order their equipment for the year, they have to do three things; enter/update their personal information (personal.php), fill out fields in the contract (contract.php), and complete a questionaire on their home club (questionaire.php).

Once that is done, they will get to a menu page where they can order equipment, go back and update personal informa tion, and do other things. They way I'm controlling this is by using three Y/N fields in the player table that indicate whether or not these three steps have been completed. Once each step is completed, the appropriate field is updated, and they go to the next step. When all three steps are complete, they will be taken to the menu page.

This way, they can't get to the menu page until the three steps are complete, and if for some reason they bail between the first and second steps or between the second and third steps, when they log back in, they just pick up where they left off.

After reading through old posts on sessions and using header() to redirect the user to the appropriate page, I decided to use a couple redirect scripts for processing the form. So, for instance, when the user first logs in, redirect.php looks in the database to see which steps have been completed and redirects the user to the appropriate page. Here is the code:

View Replies !
Header Function To Redirect A Page
I am using the header function to redirect a page. Which works great except when I want to send info to the redirected page.

example:
2 pages
a.php
b.php


If I am on page a.php which has a form on it and I hit submit there which normal refreshes back to its self but one of the check boxes are checked I have it redirecting to page b.php. The redirect works great but I would also like the rest of the variables that where submitted in the form to be accessed on page b.php.

Is that at all possible?

View Replies !
Use The Header(); Function To Redirect To Other Pages
I've been trying to use the header(); function to redirect to other pages such as... Login not successful *redirects to login page*. but whenever i try to use the header it says that its being used by another line already. and no where in my code is there another line like it. what does this error mean and how do i fix it?

View Replies !
Can't Get Header Redirect Code To Work
I'm using mod_rewrite on a website that i'm developing, and i want a handler on my index file which redirects to a 404 header if the content is not found. I've written this code that's suposed to redirect to a 404 header, if the content is not found: Code:

View Replies !
Session Dies After Header Redirect
I noticed that PHP.NET said to do a HEADER Location: for a client re-direct. When I do that thoughm it seems either the session is destroyed, or the ID is lost. If I set session variables, then do a Header redirect, the variables are empty at the new page. While I *could* just say "You are now logged in, click here to continue", tht sounds kind of silly to me. Any other way?

View Replies !
Htaccess And Php Header Redirect Problems.
I was running a site on a semi-dedicated server and 2 days ago I switched to a brand new hosting company for a dedicated server.

When the site first started working, I noticed header errors saying the session output or headers were already being started by output. I dont remember the exact error but I know it said something about headers and sessions. Code:

View Replies !
Difference Between Link And Header Redirect
What's the difference, if any between a hard link and header('Location: ...')

Clicking on link versus being re-directed to the destination via header() -- are there any difference from perspective of the destination site?

I am interested to know this to implement Affiliate logging. i.e. affiliate links implemented using re-direct? Will the affiliate cookies be set if I use the header() redirect?

View Replies !
IF Statement Header Redirect Error...
ok i'm using this code now to redirect the site to a certain page depending on the user's role which is calculated from the username using a SQL query. Code:

View Replies !
How To Redirect After (header) After Sending An Alert Message
I have a php script that checks whether the user is allowed to perform an
action. If he is not allowed; I display a warning; using the alert function.
After clicking away this function, I want to redirect the user to the
original page using the header function.
However, I get the normal message " headers already sent"... I know what
the problem is.
But how do you normally deal with this situation? use a html/php for the
warning instead of alert message? or is there another way?

View Replies !
Php Redirect - Warning: Cannot Add Header Information - Headers
I'm trying to redirect to a new php page:

header("Location: http://skunkworksdev/sarah/page2.php");
echo "";
exit();
Why do I get this warning???

Warning: Cannot add header information - headers already sent by (output started at /var/www/skunkworks/sarah/page.php:5)

View Replies !
Page Continues Parsing AFTER A Header() Redirect?
i was just misunderstanding the way the header() redirect works. Is it true that PHP code continues to parse beyond a line like

header('Location: http://www.someurl.com');

EXAMPLE: Would CODE PORTION 2 still execute? Because it is for me...lol

CODE PORTION 1
CODE PORTION 1
CODE PORTION 1
header('Location: http://www.someurl.com');
CODE PORTION 2
CODE PORTION 2
CODE PORTION 2

View Replies !
Header Location Redirect Interfering With Script -
A script i'm working on is behaving real strange. It is more or less
the same as dozens of others that work aok.

Info is posted from one script to another, the second script does some
work (nothing too taxing, just checks the input and updates/moves a
couple of files) then redirects to the first script. Code:

View Replies !
Header Redirect = Error In Internet Explorer
my members of my site have been complaining lately of after posting comments and stuff on my site that they get a blank error page, so today I investigated moire to see what was going on, it seems it only happens in internet explorer Code:

View Replies !
Redirect A Page Without Using Header("Location:
is there a way to redirect a page without using header("Location: this one can be used only if you position it on top of the page, before sending any other data. i want to redirect the page after some contents displayed.

View Replies !
Redirect To My Homepage Without Using The Standard Header Command
I have a php contact script and I want it to redirect to my homepage without using the standard header command.

<?php
header("location:http://www.johndoe.com/index.html");
exit;
?>

View Replies !
Cannot Modify Header Information - Headers Already Sent By - Redirect The User
I am getting this error:
Cannot modify header information - headers already sent by

when I issue a
header ("Location: http://www.foobar.com");

How can I redirect the user to such a site without encountering this error.

If I run the same code on two sites I will get the error on one site but
not the other.

An I can t figure out what setting in the php.ini that is different.

How can one send a refresh in 0 seconds to the broweser?

View Replies !
Redirect - Header('Location: Xmlorderon.php?order_id=$order_nummer');
What's wrong with that?

I have a variable

$order_nummer = "C.45";

Then I redirect to

header('Location: xmlorderon.php?order_id=$order_nummer');

but I my location bar I see:

http://localhost/pcGebruik/files/xmlorderon.php?order_id=$order_nummer




View Replies !
Easy Redirect Question...i've Read The Header Thread..please Help
Hi I have a php script with an If statment that fires if a user successfully logs in which then prints a success message...but instead of a success message i want the user to be automatically redirected to a diffrent html page....I tried to use header but as you can guess I get a header has already been sent error so how should i write the code so that i can redirect the page if  successful login?

View Replies !
Html Redirect
The website I have taken over has a lot of bagage. Every page has the side menu. so changing a link is a nightmare. All the pages are html. I want to replace one with PHP. Without going through every page to change one link, is it possible to have a dummy html page that re-directs to the PHP page. header('Location: ..) works in PHP but I need a html redirection here.

View Replies !
Redirect HTML ->
I have a site that is about to transition from all HTML pages to all PHP pages. The page names will remain identical with only the extensions changing. Is there a simple solution so that anyone coming in via bookmarks or search engines and accessing a .html page will be seamlessly forwarded to the identical .php page?

View Replies !
Redirect To The HTML Page
I have a page which is all PHP processing. It outputs errors via echo.

Since I am using echos for errors, I can not use header("location:http://wwhatever.com") after the code to redirect to the HTML page depending on the success of my operation. The user arrives at this page after clicking a submit button. Form action gets me to the page. The page is all PHP right now.

What is a good way to get around this? I do need the echos in case there are errors - also to keep the user apprised of what is happening in the processing.

View Replies !
HTML Form + Redirect URL
I have two other things I'd like to do, one is I want the user be able to browse their files upload and send me a file via the same contact form. I have the HTML in the doc, but I need the script to make it work. I also would like to redirect them to a thank you page when they hit submit, instead of sending them a text message. Here's the code I have so far....

if(!$mail->Send())
{
echo "<b>Your query was not sent. Please try again later.<b>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
else
echo "<b>Thank you for your interest in xxxxxx! Someone from our sales team will contact you within 2 business days.</b>";

?>

View Replies !
Redirect To Html When Apache Is Down
I am running the apache server from home and my website from an php unsupported web server. I need a way to see if the appache is running to access on_air.php, if not redirect to an html page on my webserver. Remember my server doesnt support php, so I am looking for an if then kind of statement.

View Replies !
Php Location Redirect In A Html Page
I'm having trouble including this php into a html page. I can't rename the file as a .php file it must be in html. Code:

View Replies !
Can You Redirect Every Existing Html Page Through A Php Function?
Is there a way to redirect every single page on an existing web site through
a php function?

In other words, say I have a whole functional HTML web site, never written
to use any php. Now I would like to have a php function handle displaying
every page, for example, instead of:

http://www.mysite.com/mypage.html

you would call:

http://www.mysite.com/dopage.php?p=mypage.html

....and then the php could do some fancier includes at the end of each page,
etc., or add a header, etc.

I don't want to rewrite the whole site and rename all the pages; also, this
site has been around for awhile and there are a lot of links floating around
the internet to direct urls on the site, so I'm wondering if I can intercept
every URL to that site and redirect it to the php function, which will then
open the page.

View Replies !
Header Function Into Html
i am trying to put an header function into html, but it doesn't work. Am I put the function wrong or what? Below is my script.

<? header("Cache-Control: no-cache, must-revalidate");?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

View Replies !
Can I Output Html And Still Use Header()?
I have a php script running on my localhost which on completion redirects to another script (itself actually - but with different parameters) using header(). It takes about 10 seconds for each script/page to load/run. Is there any way I can output some text without stopping header() from working?

View Replies !
Warning: Cannot Modify Header Information - Redirect From Login Page To Logged In Page
I am trying to redirect from login page to logged in page, but using the {header( 'Location: C:wampwww' ) ;} is giving me this error {
Warning: Cannot modify header information - headers already sent by (output started at C:wampwwwpassword.php:14) in C:wampwwwpassword.php on line 35}, find below my code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved