我正在做一个移动网站,想用我的iPhone浏览器测试一下。我的Windows 7电脑和iPhone都在同一个无线网络上。如何从iPhone访问localhost ?现在我得到一个404错误。


当前回答

我想完成与最初请求相同的事情,并在这里寻找答案,并关闭了所有防火墙和病毒防护,但都无济于事。

然后,我在微软文档中找到了以下关于IIS express的声明: “IIS express不向另一台计算机上的浏览器提供请求,使其在企业环境中更容易获得批准”。

底线-你将不得不安装IIS(不是交付的IIS express)来让你的项目在你的计算机之外被看到。

来源: http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx

希望这对那些正在发疯地关闭电脑上所有安全功能的人有所帮助。

其他回答

步骤:

我假设您已经启动了web服务器(默认端口:8080上的apache tomcat)。

windows 10下:

打开你的防病毒软件,进入防火墙部分,并找到端口 ,并添加“本地TCP/IP端口:8080”允许访问 从命令提示符获取机器IP地址。(IPv4地址) 从iPhone启动chrome浏览器,转到ip地址:8080地址。

希望这能有所帮助。

试试这个:

按Windows + R 打开cmd 执行命令ipconfig(旧)ifconfig(新) 检查你的无线网卡IP 打开iPhone,导航到“http://xxx.xxx.xxx”。Xxx /"通过浏览器。 (xxx.xxx.xxx。xxx是你的IP)

注意:你必须在你的防火墙设置上设置权限,如果有的话。

For Mac users, open up the Network Utility (You can find this by typing cmd + space which will open spotlight and then in spotlight start typing Network Utility). Select Network Utility, when it's open, your IP address will be found next to the label IP Address. So basically with the IP, you can get into any open ports on your local mac e.g. if your website is running locally on localhost:3000 and your ip address is 154.31.92.0 then from your phone you can get the website simply by typing 154.31.92.0:3000 into a browser.

PS-这只适用于手机和电脑在同一个网络上

您可以使用计算机的ip代替http://localhost。

但它可能无法访问。您必须编辑服务器软件的httpd.conf(或等效的配置文件)。我现在没有安装php,但你可以搜索关键字:“允许从或/目录”

注意:运行XAMPP的PC的IP必须是静态IP(不是DHCP分配的),否则每次重启PC时都需要手动检查。

找到你系统的IP地址和你运行网站的端口。

假设您的IP地址是121.300.00.250,端口是8080。

[端口号:在运行页面时看到您的web浏览器,例如:localhost:8080/…]那么端口号是8080]

现在在你的手机转到121.300.00.250:8080/..你会找到你的网站。

重要提示:您必须确保您的服务器(例如Apache Tomcat)处于启动状态