开发者

open url through header in php

I have a .php file in which i have a added a simple code:

<?php
header("Location:http//www.google.com");
?>

when i run this code, then instead of opening开发者_运维技巧 google.com it opens a download file, which is the same as my php file.


You have to make sure your server is setup to parse php files.

Something like this in apache:

AddHandler php5 .php .php5

edit

You would add this in the apache configuration file. httpd.conf

Take a look at this article. It walks you step by step on how to do this. I am assuming you are using windows.


You need a space after Location: for the redirect to work properly. Also, make sure you have the colon after http.

Try

header("Location: http://www.google.com"); 


You need to install/enable you server's php module, or if you are in windows, download WampServer and install it.


Surely you meant

<?php header("Location: http://www.google.com"); ?>

?


Are you running on a server? If not, download XAMPP and put your PHP file in the htdocs folder. Then click xampp_start.exe in the main folder. Then go to localhost/youphpfile.php in your web browser.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜