How can I replace Apache HTTP code 404 to 200

后端 未结 3 1038
遥遥无期
遥遥无期 2020-12-06 21:52

I don\'t want the apache of a website return any HTTP code 404,
the reason is that the accreditation council will scan all the website,
many javascript links and

相关标签:
3条回答
  • 2020-12-06 22:24

    From: http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html

    1. Create a blank file in your main web directory named 404.. can be blank.
    2. Add this to your .htaccess file:

      Redirect 200 /404
      ErrorDocument 404 /404
      

    That will change the Apache ErrorDocument to the /404 file. But the Redirect line causes requests for /404 to issue a 200 OK response instead of a 404.

    If that doesn't work it is due to rewrites no doubt. So if that's the case add this under those first 2 lines but above any other rewrite lines in your .htaccess file:

    Options FollowSymLinks ExecCGI
    
    RewriteEngine On
    RewriteBase /
    
    # If the requested file doesnt exist
    # and if the requested file is not an existing directory
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^[^4]* /404 [L,S=4000]
    

    Explained in more detail at: http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#Automate_ErrorDocument_Triggering

    0 讨论(0)
  • 2020-12-06 22:32

    i think you can use this below simply code into PHP:

    header("HTTP/1.1 200 OK");

    you can test it.

    0 讨论(0)
  • 2020-12-06 22:51

    I use this:

    <?php header("Status: 200 OK"); ?>
    

    This code has to be put at the top of the .php file in the first line of code. Search engines, crawlers, browsers and anyone accessing the site will see the errordocument 404 page as a header 200.

    Header 200 means the page exists. Google will crawl and index sites with header status 200.

    0 讨论(0)
提交回复
热议问题