Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Localhost on Panther

Localhost on Panther
Thread Tools
Forum Regular
Join Date: Jun 2003
Location: San Francisco
Status: Offline
Reply With Quote
Oct 14, 2005, 05:04 PM
 
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
Reply With Quote
Oct 14, 2005, 07:47 PM
 
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
     
Mooga2  (op)
Forum Regular
Join Date: Jun 2003
Location: San Francisco
Status: Offline
Reply With Quote
Oct 14, 2005, 11:12 PM
 
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
Reply With Quote
Oct 15, 2005, 08:05 AM
 
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
     
Mooga2  (op)
Forum Regular
Join Date: Jun 2003
Location: San Francisco
Status: Offline
Reply With Quote
Oct 15, 2005, 12:09 PM
 
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
Reply With Quote
Oct 15, 2005, 12:28 PM
 
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
Reply With Quote
Oct 15, 2005, 12:33 PM
 
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
Reply With Quote
Oct 15, 2005, 12:36 PM
 
I think jay3ld was right; I might've changed my http.conf. Which IIRC, is in file:///etc/httpd/
     
Mooga2  (op)
Forum Regular
Join Date: Jun 2003
Location: San Francisco
Status: Offline
Reply With Quote
Oct 17, 2005, 04:44 PM
 
Hey thanks, Jay... that worked just like I had hoped! Awesome.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:39 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2