Reputation: 765
I have a fairly simple requirement. I have a multisite WP setup where I create all my new themes for various clients. I keep the content simple so the db is pretty small. I'm running all this on Apache on Mac, just the default install.
I can access these multisites through localhost, but when I try to access them through mobile, I don't get any css or images. I know it's because the mobile host is trying to access the localhost url which means nothing to the phone.
Is there anything I can do, like with say, the hosts file or the httpd.conf to sort this out so that the CSS and images will work on mobile? I tried using the IP address of the machine as the URL of the site, but with DHCP, this has changed with a reboot and I don't want to have to keep resetting the IP anyway.
Any feedback would be much appreciated.
T
Upvotes: 1
Views: 2750
Reputation: 1289
You can always use System Name instead of IP if you are in DHCP environment. Your system name should always be the same whereas your machine IP may change on every restart.
Otherwise you can use Dynamic DNS to link one of your free domain (if you have any) with your machine and access it from any where.
Upvotes: 1
Reputation: 1665
I think your best bet is to use No-IP.com to give your internal host IP a "real" domain name. You can do the same using host files, but obviously this is tricky (or maybe impossible) on a mobile phone.
Upvotes: 2
Reputation: 89847
Always use relative URLs within your HTML.
If you have a page containing <a href='http://localhost/some_image.jpg'>
, obviously the image will only be served to someone accessing the HTML page on the local machine.
However, if instead you use <a href='/some_image.jpg'>
, the image will be fetched from the same hostname/IP address the HTML page was fetched from, whether the client sees it as "localhost" or "somehost.dynamicdns.example.com" or "123.456.789.111".
Note that this all assumes that your server will actually serve the content to non-localhost clients, although it seems unlikely it's not if you're seeing the HTML but not the images and CSS.
Upvotes: 0