Credit to this website: https://www.thakkarworld.com/localhost-website-android-phone.html
When we build a page/website in localhost/local PC using XAMPP or WAMP server, we only can access it only in our computer. We type localhost or our IP in a browser, then our webpage will appaear.
But how to access it from our phone through our WIFI network or hotspot ? Here in this article, I will provide complete guide on How you can open localhost website on your mobile phone?
Suppose the environment is:
- WIFI network – mobile hotspot
- PC as localhost – XAMPP server is installed. You can refer to my last tutorial for installed XAMPP:
Step 1: Open the Download the XAMPP Installer:
- First of all, I assume that you have tested your website completely on desktop and working fine using XAMPP server in localhost.
- On the XAMPP papel, click the bar Config and bar go to XAMPP -> Apache-> httpd-xampp.conf and edit the file or C:\xampp_new\apache\conf\extra\httpd-xampp.conf.
- You can opened it by editor like Sublime Text 3.
- In the file find the text “Require localhost” and replace it with “Require all granted”. Now save and close the file.
- Restart XAMPP Server by click stop and click start again.
Step 2: Create inbound and outbound in Windows firewall
- Open control panel and search windows firewall in upper right corner search box. Now open windows firewall from search results. On the next screen click on Advanced settings in the left sidebar links.
- In Windows firewall screen, Click on Inbound rule. As per below image click on New Rule which is located in right sidebar. It will pop up new screen to configure the inbound port.
- In the configuration wizard, Select Port as per above image in Rules type page and click next.
- Now Select Port type as TCP and specify port on which your Apache server is running and click next button. In my case it is 80 so i have provided 80.
- Select “Allow the connection” action as per below image and go ahead with next screen.
- Now provide name of Rule and description and finish the configuration wizard.
- Now Inbound rule is created in windows firewall and using same steps you can go ahead
Step 3: Check the localhost IP by type ipconfig
- Open the cmd and run as administrator.
- Type the: ipconfig
Step 4: Test the connection on PC and Mobile app of the IP
WINDOW
- Open any browser and type the IP : Example: 192.168.43.41
- The result will be shown as below.
MOBILE PHONE
- Open any browser and type the IP : Example: 192.168.43.41
- The result will be shown as below.
DONE !!!
I hope above guide is helpful to all of you and you are able to open your localhost website/blog on mobile device as well.
Share this awesome article to your friends as well.
Have a nice day.