我正在做一个移动网站,想用我的iPhone浏览器测试一下。我的Windows 7电脑和iPhone都在同一个无线网络上。如何从iPhone访问localhost ?现在我得到一个404错误。
当前回答
我想从我的iphone上浏览我的Windows 8笔记本电脑上的IIS服务器托管的网站。经过一番阅读,我打开Windows防火墙,选择“允许一个应用程序或功能通过Windows防火墙”。然后向下滚动并从列表中选中“万维网服务(HTTP)”。就是这样,它起作用了。 希望这也能帮助到其他人。
其他回答
如果你宁愿输入主机名而不是IP地址
第一选择(快速方式):
您应该能够在您的iPhone上导航到http://my-macbook-pro.local/mywebsite。参见https://stackoverflow.com/a/9304094/470749
这种方法往往是有效的,因为'。域是一个特殊的保留字。
第二选择:
访问http://xip.io/,这是一个免费的服务,非常方便。无需配置。
然后,当您浏览到http://mysite.app.192.168.1.130.xip.io(使用服务器上的浏览器或LAN上的任何设备)时,它将显示托管在192.168.1.130上的页面。
如果您在该IP上存在的机器上运行Homestead,那么浏览http://mysite.app.192.168.1.130.xip.io:44300 (URL中包含端口)会以某种方式显示Homestead Vagrant虚拟机上的页面,地址为192.168.10.10。很神奇的。
第三种选择(它不依赖于服务,灵活但更复杂,只有当你有一个带有DD-WRT的路由器时才能工作):
如果您有一个本地服务器托管多个不同的站点,您希望通过不同的主机名(通过iPhone)访问这些站点,您可以这样做。
In your OS, change the name of your computer to something short, meaningful, and easy to remember, such as "RYANDESK". In your DD-WRT router settings: In Services > Services > Static Leases, set the MAC address of your server to point to a specific IP address, such as 192.168.1.108. Set its hostname to be the same as you named your computer earlier. "Client Lease Time" can be 1440 minutes. Be sure to press Save and also Apply Settings with every change. ("Save" doesn't seem to automatically apply the settings.) If you get an error, it's probably because the GUI design of DD-WRT is misleading, and you unnecessarily pressed "Add" for Static Leases. In DHCP Server > User Domain, choose "LAN & WAN". For "LAN Domain", set it to some short string, such as your initials without any punctuation (e.g. "xyz"). Probably avoid using the word "local" since there might be conflicts. Don't use real-world domains such as "com", "org", "net", etc. In Services > Services > DNSMasq, enable DNSMasq and "Local DNS" and configure "Additional DNSMasq Options" to be something like: address=/project1.xyz/project2.xyz/192.168.1.108 (where xyz is whatever you chose in the earlier step, the IP points to the specific machine, and project1 and project2 are whatever hostname you want to point to each of those projects (such as different Nginx configs). Ensure that your HOSTS file doesn't have any entries conflicting with what we've done. If you don't know what a HOSTS file is, you're probably fine. Flush your DNS cache and release and renew your local IP. Switch into and out of Airplane Mode on iPhone to flush DNS cache there too. Now you can browse to http://ryandesk.xyz in your iPhone (or in your desktop browser), and it will resolve to your local server. So hopefully you've set up your Nginx or Apache or whatever to be listening for that hostname. https://wiseindy.com/it/how-to-access-your-pcs-using-dns-names-with-dd-wrt/ http://www.howtogeek.com/69696/how-to-access-your-machines-using-dns-names-with-dd-wrt/
有一个非常简单的方法来实现这一点:
将你的手机和电脑连接到同一个局域网。 windows + R,然后输入ipconfig,然后你得到你的当前ip在你的pc,它看起来像这样:192.168.XX.XX 在你的手机web浏览器中输入这个ip,就像这样:http://192.168.XX.XX:8080,它可以工作
注意:
如果这行不通的话。关掉你电脑上的杀毒软件,如果仍然不起作用,尝试关闭windows防火墙,因为这个问题与电脑防火墙有关。
如果你使用mac (OSX):
在mac上:
打开终端 运行“ifconfig” 找到ip地址为“192.xx.x.x”的行
如果你用地址测试你的网站:"localhost:8888/mywebsite"(这取决于你的MAMP配置)
在手机上:
打开浏览器(如Safari) 输入URL 192.xx . x.x.x:8888/mywebsite
注意:必须连接在同一网络(wifi)
对于那些使用正确IP地址但仍然无法连接到本地服务器的人,另一件要检查的事情是您或您的同事没有将设备配置为使用代理服务器。
我有一台设备无法连接,结果发现该设备被配置为使用Charles Proxy,当然它没有运行。
如果你使用的是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
推荐文章
- 在代码中为UIButton设置一个图像
- 127.0.0.1和localhost之间的区别是什么
- 如何修复UITableView分隔符在iOS 7?
- 如何允许本地主机上的Apache使用HTTPS ?
- 在Swift中根据字符串计算UILabel的大小
- 如何调用手势点击在UIView编程在迅速
- 我如何隐藏在一个Swift iOS应用程序的状态栏?
- 对于实例消息,接收方类型***是转发声明
- 如果模态ViewController演示样式为UIModalPresentationFormSheet, iPad键盘将不会解散
- 在UITableView中检测哪个UIButton被按下了
- 我如何输入RGB值到接口生成器?
- NSUserDefaults -如何判断一个键是否存在
- 应用程序商店链接“评价/审查此应用程序”
- OAuth:如何测试本地url ?
- 将故事板从iPhone转换为iPad