SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Google Sitemaps and custom 404s

    Does anyone have any expertise on this? I have created a custom 404.php on my ISPs IIS webserver, but when I try to verify my sitemap.xml file I get an error that my 404 is returning a 302 header. I tried putting
    PHP Code:
    header("HTTP/1.0 404 Not Found"); 
    into my 404 page, but I was getting the same error message. Deleting the file altogether fixes the problem, but I want my custom 404!
    Not another drugstore, not another town
    Tired of the overdrop, I had to put it down
    You know I was the man when I put the Crown down
    Then rolled around the Chemicals to pave the New Sound

  2. #2
    Are You There? KDesigns's Avatar
    Join Date
    Oct 2003
    Location
    Your Monitor
    Posts
    1,146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I could be wrong but the header("HTTP/1.0 404 Not Found"); directs to the 404 page. If that's what you have on the 404 page it would create a scenario where a 302 may be returned. Like I said though, I could be wrong.
    ChooseDaily.com - Follow on Twitter
    Top Resources for Web Designers and Developers Every Day!

  3. #3
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I started without that line in my 404 page, and tried to add it, to make sure Google received it, so I wouldn't get that error message. So, I know deleting it will do no good, its the exact same error with or without the " header("HTTP/1.0 404 Not Found"); " line.
    Not another drugstore, not another town
    Tired of the overdrop, I had to put it down
    You know I was the man when I put the Crown down
    Then rolled around the Chemicals to pave the New Sound

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by KDesigns
    I could be wrong but the header("HTTP/1.0 404 Not Found"); directs to the 404 page.
    Sending that header doesn't do any redirection. It is the proper way to send a 404 from PHP, so the problem must be with IIS, perhaps sending its own header first? Not sure, all my servers are Linux.

    Tested:
    Code:
    <?php
            header("HTTP/1.0 404 Not Found");
            exit;
    ?>
    Quote Originally Posted by Web Developer Toolbar
    Response Headers - http://www.w3counter.com/404.php

    Date: Fri, 02 Jun 2006 14:27:10 GMT
    Server: Apache
    X-powered-by: PHP/4.4.2
    Connection: close
    Content-Type: text/html

    404 Not Found

  5. #5
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I kind of figured out what I need is output buffering, a little snippet of code to confirm that a page exists and is kosher before I "header" it.
    PHP Code:
    if ((!(preg_match('/php/'$url))) && (!(preg_match('/htm/'$url)))){
        
    $url $url.'.php';
        
    //////////////does page exist?
        
    header("Location: $url"); 

    I want to include this in my 404.php, but I want to provide for a mechanism to forward "clean urls", such as, if someone puts http://www.nasi.com/cae into their browser, it will forward onto http://www.nasi.com/cae.php. I tried looking up some things on php output buffering, but does anyone have any ideas?
    Not another drugstore, not another town
    Tired of the overdrop, I had to put it down
    You know I was the man when I put the Crown down
    Then rolled around the Chemicals to pave the New Sound


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •