【发布时间】:2019-06-07 17:06:10
【问题描述】:
我正在尝试找到一种通过 .HTACCESS 将 404 和 503 错误(以及类似类型)重定向到页面的方法,但会添加一些附加值。
示例 - 如果有人登陆 404 错误页面,链接通常如下所示: https://www.yourdomain.com/pages/404
你会如何得到它:
https://www.yourdomain.com/pages/404?submit=error&msg=3
(在 POST 或 GET 数据中)
这个问题翻译了我正在寻找的部分内容,但并不完全(因为答案显然是“否”): Can I use .htaccess to convert a url slug to a POST request?
这可以做到吗,如果这样做会不会有任何安全隐患?
这是在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;
}
}
【问题讨论】:
-
@mplungjan 我会检查的,谢谢。 (我意识到,如果您精通某事,您将能够在 Google 上找到任何东西。作为一个初学者,甚至不知道这是否可能,我什至用一千次谷歌搜索都找不到它。)跨度>
-
我不确定这是否可能,我只是想给你一个相关的搜索