欢迎各位兄弟 发布技术文章
这里的技术是共享的
header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . $location);
where $location
is the path after the domain, starting with /
.
许多不同的$ _ SERVER
(文档)返回有关当前页面的信息的属性,但我的首选方法是使用$ _ SERVER ['HTTP_HOST']
:
标题(“位置:” 。 “HTTP://” 。$ _ SERVER [ 'HTTP_HOST' ] 。$位置);
其中,$位置
是域之后的路径,从/
。
I i am not sure why it is not redirecting, maybe i did it wrong? $location= '/index.php'; header("Location: " . "http://" . $_SERVER['HTTP_HOST'] .$location); – user710502 Nov 15 '11 at 3:21 | |||
| For debugging, simply output that string with echo instead of header . If it is correct, then something else is wrong (headers must be the first output on the page, for example.) – NickC Nov 15 '11 at 3:24 | ||
@Goose Thanks, fixed! – NickC Jan 5 at 0:07 来自 http://stackoverflow.com/questions/8130990/how-to-redirect-to-the-same-page-in-php |
how to redirect to the same page in php
如何重定向到PHP中的同一页
How can i redirect to the same page using PHP. For example in local my web address is
How can I redirect within my website to another page say
I know this might be wrong, but do I really need to put the whole thing?, what if later it is nothttp://localhost/ ?
Is there any way to do something like this?. Also, I have a lot of code and then at the end after it is done processing some code.. I am attempting to redirect using that, is that ok?
我怎样才能重定向到使用PHP同一页面。例如,在当地我的网络地址是如何将我的网站中的重定向到另一页说
我知道这可能是错的,但我真的需要把整个事情?如果以后有什么不可以的http://本地主机/?
有没有办法做这样的事情?另外,我有很多的代码,然后在它到底是做了一些处理代码后..我尝试使用重定向,可以吗?
There are a number of different
$_SERVER
(docs) properties that return information about the current page, but my preferred method is to use$_SERVER['HTTP_HOST']
: