I'm trying to find a way to redirect 404 and 503 errors (and similar types) to a page via .HTACCESS, but with some added values.
Example - if a person lands on a 404 error page, the link would normally look like: https://www.yourdomain.com/pages/404
How would you get it like:
https://www.yourdomain.com/pages/404?submit=error&msg=3
(in POST or alternatively GET data)
This question translates part of what I'm looking for, but not quite (as the answer is clearly 'No'): Can I use .htaccess to convert a url slug to a POST request?
Can this be done, and are there any security implications if it was done?
This is in error_page.php:
if ((isset($_GET['submit']) && $_GET['submit'] == 'error') || (isset($_POST['submit']) && $_POST['submit'] == 'error')) {
$success_message = mysqli_real_escape_string($conn, $_POST['msg']);
switch ($success_message) {
case '2':
echo "<h2>Page under Maintenance</h2>";
echo "<p>This page is currently undergoing some critical maintenance. You can try again in a couple hours.</p> For any help or enquiries send us a message on ".$support_email."";
break;
case '3':
echo "<h2>404 Page Not Found</h2>";
echo "<p>It seems the page you're looking for doesn't exist...</p>";
mail($errors_email, 'Alert: 404 Not Found', 'A user (ref '.$user_ref.' with IP address '.$ip_address.') landed on this page ('.$current_url.') from '.$previous_url.' with a 404 error. Care to see what went wrong?');
break;
default:
mail($errors_email, 'User Landed on an Unknown Error Page', 'A user ('.$user_ref.') landed on the success_template.php page and something went wrong. This is just an alert to test all of the forms pointing to this page to see if they are valid.');
break;
}
}