I’m trying to make access to my MAMP localhost
from my mobile phone and other Windows PC. I’m currently using a Mac.
While I can see the database content but the website doesn’t render as usual (no images, stylesheet, etc…).
Therefore I assume the other PC can access the database but can’t use the files. Maybe the PHP files are not processed?
Does anyone have a suggestion on what could be the cause and how to fix it?
However I can see the database content but the website doesn't render as usual (no images, stylesheet, etc)
Does your site on the MAMP install use hardcoded URLs for CSS, images & JavaScript? Something like this:
http://localhost/images/a_great_image.png
If so, when a remote host accesses your site, they will not be able to see the content on URLs like that since they will be pointing to localhost
and localhost
is an address directly connected to the local machine. Meaning that any machine will only see localhost
as their actual machine; never a remote machine. It’s a loopback hostname for testing & restricted local access.
The two solutions you have is to do the following:
localhost
address to be the IP address of your computer on the network. So if your computer is reached via the IP 10.0.1.3
, then the URL would be: http://10.0.1.3/images/a_great_image.png
./images/a_great_image.png
and maybe use base
tag like this <base href="http://10.0.1.3/" target="_blank">
on each page. That way all your links in URLs are relative, but the base
is set once & is always http://10.0.1.3/
.