从 localhost 重定向到 localhost/abc/ [英] redirect from localhost to localhost/abc/

查看:122
本文介绍了从 localhost 重定向到 localhost/abc/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have placed an index.php file in the root of my web site (http://localhost).

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

I want to redirect this page (http://localhost) to http:/localhost/abc - when I visit http://localhost, I want the user to go to http://localhost/abc.

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

What do I need to do to my index.php file?

推荐答案

在你的第一个 index.php 中这样的东西怎么样:

What about something like this in your first index.php :

header('Location: http://localhost/abc');
exit;

(顺便说一句,您在 OP ^^ 中的http:"之后忘记了一些斜线)

(BTW, you forgot some slashes after 'http:' in your OP ^^ )

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

Anything/anyone that comes to this first page will be redirected to the 'abc' one.

有关详细信息,请参阅 header.

See header, for more informations.

一件事:在调用 header 函数之前确保没有任何东西被发送到输出,否则你可能会得到一个错误:如果有任何输出 (如 HTML 代码,或甚至空格!) 已经生成.

One thing : make sure nothing is send to the ouput before calling the header function, else you might get an error : headers cannot be sent if any output (like HTML code, or even white spaces !) has already been generated.

这篇关于从 localhost 重定向到 localhost/abc/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆