简体   繁体   English

仅重定向到index.html一次

[英]Redirect to index.html only once

I'm very new to php and am working to write a script that will have the url (myurl.com) a user visits redirect to myurl.com/index.html (working with Wordpress & adding a temporary landing page), and from there, you'll be able to access an unrelated link, and then will have the option to continue on to myurl.com and access the Wordpress website like normal. 我是php的新手,正在编写一个脚本,该脚本将使用户访问的URL(myurl.com)重定向到myurl.com/index.html(与Wordpress配合使用并添加一个临时登录页面),并从在那里,您将能够访问不相关的链接,然后可以像往常一样继续访问myurl.com并访问Wordpress网站。 So far, this is what I have. 到目前为止,这就是我所拥有的。

isset($_GET['home'])?$home=1:header("Location:http://myurl.com/index.html");

but of course, this is still redirecting when you're on myurl.com after continuing on from the redirect. 但是,当然,从重定向继续后,当您访问myurl.com时,它仍在重定向。 Any help/advice would be great! 任何帮助/建议都很棒!

You are checking for home but not setting home thus the loop. 你检查home ,但没有设置home所以环形。

You can pass the home variable in with the URL request - let me know if this does not work for your situation: 您可以将home变量与URL请求一起传递-如果这不适用于您的情况,请告诉我:

if (!isset($_GET['home'])) {
    header("Location: http://myurl.com/index.html?home=1");
} else {
    // Home is already set dont redirect
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM