[RESOLVED] Keeping stuff on localhost from being accessed by other sites.
I keep a mirror of every site I run on my hard drive, so that I can work with them. Sometimes, however, I run into a problem if I use a <base> element: I forget to upload the include for the site, and my viewers get <base href="http://localhost/...">, which clearly causes problems.
How do I set up localhost so that files from localhost can ONLY be accessed on a localhost site?
Try using a config file to set things like base url, data base info, etc. (like most cms) and use one copy for localhost and a "live" copy for the live site.
Do the same with your .htaccess file... there could be conflicts between localhost and live server there also.
Are your sites static or dynamic?
In general, using <base> in a static site makes portability a little more difficult because you need to change the base reference on each page.
An option would be to "embed" PHP in your html or use ssi (cgi)... allowing you to include text from a (config) file.
Dynamic. And yes, I use <base>. I have one head include for localhost, one for the live website. Basically, what I want is this: If I upload the wrong head include, I want my stylesheets not to work and images not to show up, so that I know at once something is wrong.
now I'm confused!
what is the problem again? unless your hard drive is accessible to the general public via internet... possible, but NOT a good idea, and you are using your internet IP address and route to your localhost in your <base> (not 127.0.0.0) you can't see the photos from your hard drive on the live site.
Okay. For the mirror on my computer, I have the following base URL:
For the live site, I have:
Both are contained in a file known as "head.htm". If I upload the wrong "head.htm" to the site, then the live site will point to "http://localhost/FBA/". All fine and dandy for me, since my browser can find it, and I don't notice anything's amiss until someone emails me and asks me why the site is not working. What I want is to keep my CSS files and images from being hotlinked from my localhost so that if I upload the wrong "head.htm", the site won't work for me.