[英]404 error when using PHP redirect to an existing page
I am attempting to redirect users to a success page when their payment is complete. 我正在尝试在用户付款完成后将其重定向到成功页面。 This is how the code looks:
代码如下所示:
<?php
session_start();
$total = $_SESSION['total'];
require_once('stripe-php-2.3.0/init.php');
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("");
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = \Stripe\Charge::create(array(
"amount" => $total, // amount in cents, again
"currency" => "gbp",
"source" => $token,
"description" => "")
);
header('Location: index2.php');
} catch (\Stripe\Error\Card $e) {
// The card has been declined
}
?>
The code does redirect and the address in the browser's address bar is the one that I want and is on the server however I get a 404 error each time. 代码会重定向,浏览器地址栏中的地址是我想要的地址,并且在服务器上,但是每次都会收到404错误。
检查您是否有任何URL重写规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.