Using PHP to Make Site-Root Relative Link Variables

I’m trying to figure out a good internal linking system(s) for my websites. I generally use relative links for my “bread crumbs” style links (North America > U.S. > Alaska), but I’ve never really perfected it.

I just discovered site-root relatives links, which look pretty exciting. I tried it on one of my sites, and it appears to work perfectly. However, I was told that they won’t work online. After all, my local site is named “geoworld,” while the online domain is “www.geoworld.org.”

(Below is an example of a site-root relative link used with an image.)

I was advised to use Apache to convert each my sites to virtual hosts. I spent an entire day wrestling with that, but it was a total disaster. But before I abandon this experiment entirely, I wondered if there might be some way to use PHP to make variable links that will work both locally and online.

Here’s a rough idea:

Kenya

When I preview the page on my computer, the link would translate like this:

Kenya

And when I view it online, it would look like this:

Kenya

Does anyone know how I can do this?

Thanks.

Relative links will work fine. If you dont specify the http:// part then the browser will just fill that in for you. I have never had a problem working with a site lcoally and then uploading it and have it not work. By locally I’m assuming you are using a web server, Apache or IIS and have PHP installed and running. If you don’t have this setup then using PHP locally will not work. Could you give us a link to a page that you are having a problem with? As for your question,

Can PHP be used to make variable links that will work both locally and online.
I don't think it's a PHP issue really. It's more of an html issue. I don't see an issue with how you have your links setup, although I do find it strange you said
my local site is named "geoworld," while the online domain is "www.geoworld.org."
Could you give us more details. It sounds to me like you are putting everything in a local file called geoworld but when you upload it to the live server you don't upload the geoworld folder, only the contents of it. I may have confused you and myself, so provide more info if you can.

Keith[/quote]

Sponsor our Newsletter | Privacy Policy | Terms of Service