Преглед на файлове

add Custom 404 page and Custom Headers for WebServer.check 404 file exist or not.

Linkec преди 7 години
родител
ревизия
818b3cce49
променени са 1 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 3 3
      WebServer.php

+ 3 - 3
WebServer.php

@@ -225,10 +225,10 @@ class WebServer extends Worker
         } else {
             // 404
             Http::header("HTTP/1.1 404 Not Found");
-			if(isset($workerman_siteConfig['custom404'])){
-				$html404 = '<html><head><title>404 File not found</title></head><body><center><h3>404 Not Found</h3></center></body></html>';
-			}else{
+			if(isset($workerman_siteConfig['custom404']) && file_exists($workerman_siteConfig['custom404'])){
 				$html404 = file_get_contents($workerman_siteConfig['custom404']);
+			}else{
+				$html404 = '<html><head><title>404 File not found</title></head><body><center><h3>404 Not Found</h3></center></body></html>';
 			}
             $connection->close($html404);
             return;