开发者

Having redirect issue

开发者 https://www.devze.com 2023-04-01 04:54 出处:网络
I\'m using directorystructure(for redirecting from other pages for example after succesful registration) with header("Location: ../../../index.php"); function. It works in local server well

I'm using directory structure (for redirecting from other pages for example after succesful registration) with header("Location: ../../../index.php"); function. It works in local server well but in remote one getting error message

Now, If I put localhost/ it will work in my local webserver but not in remote one. If I put the exact address of the web page then it will not work in my local server. How can I generat开发者_StackOverflow中文版e websites (main pages) URL with PHP? Is it possible?


use this:

header('Location: http://'. $_SERVER['HTTP_HOST'] . '/');

This will take you to the homedirectory of the server (note, if running locally you need to have your virtualhosts configured correctly but not hard to do).

If you need to direct to a specific directory or file, just add after the '/' above.


Try this:

$cwd = dirname(__FILE__);
header("Location: $cwd/../../../index.php");
0

精彩评论

暂无评论...
验证码 换一张
取 消