I am working on a mobile website and would like to test it using my iPhone browser. My Windows 7 machine and iPhone are on the same wireless network. How do I access localhost from the iPhone? Right now I get a 404 error.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
- XCode 4.5 giving me “SenTestingKit/SenTestKit.h” f
If you're on a mac make sure to edit your
/etc/hosts
file. Find the IP address per instructions above and add the following line to that fileAfter that, the steps above worked: navigate to the right page in my iphone browser, visit http://172.x.xx.x.x:port http://www.imore.com/how-edit-your-macs-hosts-file-and-why-you-would-want
If you are using Mac, go to System Preferences > Network and use your IP address instead of localhost. You can also use port number. In my case, I have a server running on port 1448 and I can preview 192.168.1.241:1448 using iPhone.
you can try ngrok.io. Works on same principle as localtunnel.
Download the application for your os. and try to run like:
for linux:
8000 is port number your application is running on.
for windows:
If you go the route of going into your Network Settings and getting Wi-Fi IP address such as xxx.xxx.x.xxx:9000 (:9000 or whichever port is open), make sure your mobile device is also on that same Wi-Fi/signal IP address. I spent a day trying to get this to work and it didn't work until i switched my phone off the cellular network to the same Wi-Fi connection/IP address. Opened right up once I made this update.
If you are not on the same network you could use this third party tool called localtunnel
http://localtunnel.me/
It basically routes your content through another server and you access that.
If You'd Rather Type A Hostname Instead of IP Address
First Option (Quick Way):
You should be able to navigate to
http://my-macbook-pro.local/mywebsite
on your iPhone. See https://stackoverflow.com/a/9304094/470749This approach tends to work because the '.local' domain is a special reserved word.
Second Option:
See http://xip.io/, which is a free service and is super convenient. No config necessary.
Then when you browse to http://mysite.app.192.168.1.130.xip.io (using a browser on your server or on any device on your LAN), it will show the page hosted at
192.168.1.130
.And if you're running Homestead on the machine that exists at that IP, browsing to http://mysite.app.192.168.1.130.xip.io:44300 (with the port in the URL) somehow shows the page hosted on the Homestead Vagrant virtual machine at
192.168.10.10
. Pretty amazing.Third Option (which doesn't depend on a service and is flexible but more complicated and only works if you have a router with DD-WRT on it):
If you have one local server hosting multiple different sites that you'd like to access via different hostnames (via iPhone), you can do this.
Services > Services > Static Leases
, set the MAC address of your server to point to a specific IP address, such as192.168.1.108
. Set its hostname to be the same as you named your computer earlier. "Client Lease Time" can be 1440 minutes.Save
and alsoApply 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.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.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
(wherexyz
is whatever you chose in the earlier step, the IP points to the specific machine, andproject1
andproject2
are whatever hostname you want to point to each of those projects (such as different Nginx configs).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/