 |
 |
Localhost on Panther
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2003
Location: San Francisco
Status:
Offline
|
|
Hi all,
I have PHP running on MacOSX 10.4 and would like to have an IP assigned to one of my folders, so that I can take advantage of absolute URLs. To give you an example of what I have and what I want:
My current PHP address looks like this:
http://localhost/~home/webcomp/
I would like it so that I could assign a dynamic IP to the webcomp folder, so that I could just type in something like:
http://192.168.0.XXX
The point would be so that I could have all of my sites use forward slashes, which I prefer to use in web development. Links to the images folder can still just reference "/images/logo.gif".
Is this possible with my current configuration, or has anyone run across this issue? Any help would be appreciated. Thanks!
- MoO!
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status:
Offline
|
|
If you mean relative references, then you can do that now even with localhost. I have a website in my Sites folder and that's how I do it.
Chris
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2003
Location: San Francisco
Status:
Offline
|
|
Yup yup, relative references are nice for smaller sites... but when you're developing a site that may be three hierarchies deep - it is often more effective to do "/images" as opposed to "../../images".
It looks prettier, too. 
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status:
Offline
|
|
I'm not sure what you mean. All my links use foward slashes, which is what you said you were after.
My website is running fine at http://localhost/~chabig/index.html and references in it are of this form: <img src="images/portrait2.jpg" alt="" width="175" height="259">
Chris
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2003
Location: San Francisco
Status:
Offline
|
|
Chris,
Your links are using forward slashes as a means to link directories, but you can add a forward slash before your links in lieu of the domain itself. For instance if you put together a website for Yahoo.com and they have all sorts of links at different hierarchical places, you would want to use a forward slash before your links to indicate the domain host.
Your link to an image from three hierarchies up would not be "../../../images/logo.gif".
Instead, from anywhere within your site, you could simply reference "/images/logo.gif".
This basically is a link to "http://www.yahoo.com/images/logo.gif".
The forward slash is being used to reference the domain, which is useful and nice for programming. You always know where your domain starts.
The bad:
In MacOSX when you use a forward slash like that it takes you to the "localhost" and does not reference "~homedirectory". So as a testing machine when you're building large sites, your images will not be where the directory is being searched:
A link to an image on your webpage to "/images/logo.gif" would propogate the user to:
http://localhost/images/logo.gif
This is incorrect because the actual files will be at: http://localhost/~homedirectory/images/logo.gif
This messes with OSX as a viable testing machine for PHP and large sites. I'm sure there's a way around setting up directories as their own domain, but have yet to figure out how.
Regards,
- MoO!
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
make your site root something else.
its in the htpd.conf
Find And Change:
DocumentRoot "/Library/WebServer/Documents"
To:
DocumentRoot "/Users/YOURSHORTNAME/Sites"
Then Find And Change:
<Directory "/Library/WebServer/Documents">
To:
<Directory "/Users/YOURSHORTNAME/Sites">
that will change it to your sites folder in your user folder. but it still does the ~name thing. unless you disable it like i did.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Status:
Offline
|
|
You could create a local hostfile for BIND to reassign an internal IP or even fake domain name to a directory in Apache; I've never done this but have read up on it and know it would do exactly what you want. I don't do it because it's so machine-specific, and seems 'dirty'.
Anyway, doesn't your absolute linking work within /Library/WebServer/Documents ?
Mind you, I'm using Tiger, but http://localhost/ directs me right there. I think it's always worked that way. Unless I changed something...? I just tested this: create a folder called, 'test' in /Library/WebServer/Documents. In the 'test' folder, create a 'test.html' HTML document in any application, such as Dreamweaver. Drop a placeholder link to the default Apache image, or any image at root. My code was: <img src="/apache_pb.gif" alt="" name="test" width="259" height="32" id="test" />
This worked for me. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Status:
Offline
|
|
I think jay3ld was right; I might've changed my http.conf. Which IIRC, is in file:///etc/httpd/
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2003
Location: San Francisco
Status:
Offline
|
|
Hey thanks, Jay... that worked just like I had hoped! Awesome. 
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|