从localhost重定向到localhost/abc /

0 php redirect

index.php在我的网站(http://localhost)的根目录中放置了一个文件.

我想将此页面(http://localhost)重定向到http:/localhost/abc- 当我访问时http://localhost,我希望用户转到http://localhost/abc.

我需要对我的index.php文件做什么?

Pas*_*TIN 8

你的第一件事情是这样的index.php:

header('Location: http://localhost/abc');
exit;
Run Code Online (Sandbox Code Playgroud)

(顺便说一句,你http:在OP ^^' 之后忘了一些斜线)

进入第一页的任何人/任何人都将被重定向到'abc'.

有关header更多信息,请参阅.

一件事:确保在调用header函数之前没有任何内容发送到输出,否则您可能会收到错误:如果已生成任何输出(如HTML代码,甚至是空格!),则无法发送标头.