4
\$\begingroup\$

I redirect all my requests to index.php via htaccess and the code below is in my index.php.

Is this code properly set for a custom 503 page for an unsuccessful MySQLi connection trial?

Is it also proper to use these metatags?

<meta name="robots" content="noindex,nofollow,noarchive">

<?php
$mysqli = new mysqli(HOSTX, USERX, PSWX, NAMEX);
if ($mysqli->connect_errno) {
 header($_SERVER["SERVER_PROTOCOL"]." 503 Service Unavailable");
 header( 'Content-Type: text/html; charset=utf-8' );
 header( 'Retry-After: 600' ); // 10 minutes
?>
<!DOCTYPE html>
<html lang="tr">
<head>
 <meta charset="utf-8">
 <title>DB Connection Error</title>
 <meta name="description" content="DB Connection Error 503 sayfası" />
 <meta name="robots" content="noindex,nofollow,noarchive">
 <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>DB Connection Error.</p><p>Please try in 1 or 2 minutes.</p>
</body>
</html>
<?php 
 exit();
}
?>
Sᴀᴍ Onᴇᴌᴀ
29.5k16 gold badges45 silver badges201 bronze badges
asked Feb 9, 2015 at 14:16
\$\endgroup\$
0

1 Answer 1

4
\$\begingroup\$

Is this code properly set for a custom 503 page for an unsuccessful MySQLi connection trial?

The code looks okay. One might argue that notifying the user that there was a database connection error is revealing too much information. For example, if a user attempted to take the system down with an attack vector like a Denial of Service attack then such an error message could be used to determine if the attack was successful.

The exit() call may not be necessary, since it is at the end of the script.

Is it also proper to use these metatags?

It seems okay to use that meta tag for robots. Apparently sometime during the later months of 2024 the noarchive rule has no longer been supported by Google.

The new text in Google’s help document reads:

"The noarchive rule is no longer used by Google Search to control whether a cached link is shown in search results, as the cached link feature no longer exists."

This move follows Google’s earlier decision to remove the cache: search operator, which was reported last week.

answered Nov 18, 2024 at 23:57
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.