I’m having a really silly issue… basically I’m working on a site on a localhost, and a remote host… I am including files by doing the following:
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
This works a treat locally. However on the remote, while its not live, the site address is (pseudo) xxx.xxx.xxx.xxx/~user and so obviously, the js folder is xxx.xxx.xxx.xxx/~user/js/ which means my /js/jquery… include isn’t going to work.
Obviously you’re thinking I just remove the forward slash at the start of the /js and simply do a relative src – the problem with this is that I’m using mod_rewrite with clean urls, so sometimes when the file which includes the above js src is being called from a few directories deep (or so the computer thinks) ie url.com/blah/blah/blah/ so with a relative src, its going to try url.com/blah/blah/blah/js.
I’m on a php environment and I’m just wondering what the least complex approach to all this is. ie $_SERVER[‘document_root’] . ‘/js/jquery….’ is something my feeble mind tried but as you the expert probably know – its going to bring up a bunch of irrelevant unix directories and not just go to the current site root.
Any ideas?
When I’m working on various hosts with the same source code, I usually define constants for this sort of thing.
or