php - 如何将用户从 php 文件重定向回 dreamhost 上的 `index.html`

标签 php redirect

我正在 DreamHost 上设置一个简单的登录页面。它不会让我将 php 代码放入文件 index.html 中。因此,当用户提交电子邮件地址时,我使用 $_POST 将电子邮件地址提交到另一个页面 mail_auto.php

在快速看到“电子邮件已发送”消息后,我希望将用户从 mail_auto.php 引导回 index.html 页面。

header() 看起来有点复杂,似乎干扰了 mail_auto.php 平衡的执行。

重定向用户的最佳方式是什么?

最佳答案

要将用户重定向回 index.html,请使用以下命令:

header('Location: index.html');
exit;

或者,如果您想在屏幕上显示类似“正在重定向...”的内容,您可以使用 meta-refresh方法,或 JavaScript window.location使用 setTimeout 的方法

元刷新方法:

将此添加到 HTML <head> :

<meta http-equiv="refresh" content="2;url=index.html">

其中 2 是执行刷新前的秒数。

关于php - 如何将用户从 php 文件重定向回 dreamhost 上的 `index.html`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15411978/

相关文章:

asp.net - 我应该使用 301 进行站内重定向吗?

.htaccess - 获取 "mywebsite.org/"解析为 "mywebsite.org/index.php"

spring - 在 Spring MVC 中重定向到动态 URL

php - 为什么不能重定向到某些网址?

php - session 不应自行过期

python - urlfetch 重定向到 python 中的无限循环

php - PrestaShop:如果产品不存在,则重定向到主页

php - 强制浏览器重新读取ajax结果

php - 如何从 MySQL 数据库表中调用 PHP 函数以便该函数正常运行?

php - 使用 CDATA 编辑 xml 文件