我正在做一个移动网站,想用我的iPhone浏览器测试一下。我的Windows 7电脑和iPhone都在同一个无线网络上。如何从iPhone访问localhost ?现在我得到一个404错误。
当前回答
试试这个:
按Windows + R 打开cmd 执行命令ipconfig(旧)ifconfig(新) 检查你的无线网卡IP 打开iPhone,导航到“http://xxx.xxx.xxx”。Xxx /"通过浏览器。 (xxx.xxx.xxx。xxx是你的IP)
注意:你必须在你的防火墙设置上设置权限,如果有的话。
其他回答
如果你进入你的网络设置,并获得Wi-Fi IP地址,如xxx.xxx.x。xxx:9000(:9000或任何开放的端口),确保您的移动设备也在相同的Wi-Fi/信号IP地址上。我花了一天时间试着让它工作,直到我把手机的蜂窝网络切换到相同的Wi-Fi连接/IP地址,它才工作。我一更新就打开了。
如果你正在做一个php项目,你可以改变href的基本值:
<基地href = " < ?php echo str_replace("localhost","192.x.x.x",HTTPS_SERVER);?”> >
Localhost或127.0.0.1:取决于您的设置 192. x.x。X:您的本地IP地址 HTTPS_SERVER:之前的base href
这样做对于在手机上加载图像、css和js文件至关重要。
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-这只适用于手机和电脑在同一个网络上
如果你不在同一个网络上,你可以使用这个叫做localtunnel的第三方工具
http://localtunnel.me/
它基本上是通过另一个服务器路由你的内容,然后你访问它。
如果你使用的是mac,请确保编辑/etc/hosts文件。 根据上面的说明找到IP地址,并将以下行添加到该文件中
172.x.xx.x.x outer
在那之后,上面的步骤起作用了:在我的iphone浏览器中导航到正确的页面,访问http://172.x.xx.x.x:port http://www.imore.com/how-edit-your-macs-hosts-file-and-why-you-would-want
推荐文章
- 如何从同一网络上的另一台计算机连接到此本地主机?
- 如何在iOS中使用Swift编程segue
- 我如何改变UIButton标题颜色?
- Xcode 4挂在“附加到(应用程序名称)”
- 缺少推荐的图标文件-该包不包含iPhone / iPod Touch的应用程序图标,像素为“120x120”,png格式
- 如何使用Xcode创建。ipa文件?
- Xcode 4 -在新的Macintosh安装上的配置文件上“没有找到有效的签名标识”错误
- 在iPhone上确定用户是否启用了推送通知
- 是否有可能禁用浮动头在UITableView与UITableViewStylePlain?
- Swift -转换为绝对值
- 在代码中为UIButton设置一个图像
- 127.0.0.1和localhost之间的区别是什么
- 如何修复UITableView分隔符在iOS 7?
- 如何允许本地主机上的Apache使用HTTPS ?
- 在Swift中根据字符串计算UILabel的大小