Click to See Complete Forum and Search --> : relative urls


aprice42
11-09-2006, 05:51 PM
Hello,

Can anyone out there help me to understand relative urls better?

I would like to build my site with relative links, and will be using PHP to dynamically create the navigation. For pages that are within one or even two directories I will then need to change the navigation URL so that it will "relatively" find the root directory. My only knowledge of how to do this is by adding ../ or ../../ to the address until it is back to the root directory. Is there any easier way to do this?


Thanks,
Andy

Kravvitz
11-09-2006, 09:57 PM
If the relative URL starts with a forward slash ("/"), for example "/folder1/example.html", then that refers to a child folder of the web root even if the page the URL is on "/folder2/index.html".

aprice42
11-11-2006, 02:45 PM
Thanks for the info... I notice that, that this only seems to work when my files are on the web server, is there a way to make this shorthand relative address work while the files reside on my computer during my editing process?

grumpyoldtechs
11-11-2006, 03:05 PM
they should work with both if you retain the file structure locally and remotely

i rarely use absolute (well never now used to for url_rewrite but realized i was just being a n00b)

Kravvitz
11-11-2006, 04:16 PM
To make that work locally, you would need to install a web server on your computer.

I have IIS installed on this computer (it comes with WinXP Pro) and Apache on a linux box in my basement.

XAMPP (http://sourceforge.net/projects/xampp) is a very easy to install Apache (web server) Distribution for Linux, Solaris, Windows and Mac OS X. The package includes the Apache web server, MySQL, PHP, Perl, a FTP server and phpMyAdmin.

aprice42
11-11-2006, 08:14 PM
To make that work locally, you would need to install a web server on your computer.

I have IIS installed on this computer (it comes with WinXP Pro) and Apache on a linux box in my basement.

XAMPP (http://sourceforge.net/projects/xampp) is a very easy to install Apache (web server) Distribution for Linux, Solaris, Windows and Mac OS X. The package includes the Apache web server, MySQL, PHP, Perl, a FTP server and phpMyAdmin.

thanks for the advice...

I am using a mac, and am not comfortable using terminal (and it looks as though I would need to use terminal with XAMPP.

I found that if I put my files in the root directory on my computer that this method will work fine... is there any other way to setup a directory on my computer to be a root directory for my website?

Kravvitz
11-11-2006, 08:38 PM
I don't think there is another way.

Knowing basic UNIX/Linux commands is very helpful. (MacOS X is one variant of UNIX.) I prefer GUIs but can do some stuff on the command line. (I get rusty in that skill set.)

yitzle
11-12-2006, 12:07 AM
The alternative is to use ../../../ or however many needed. This will solve the root problem but returns to your original problem.
I guess you got to select which one you prefer ;)

aprice42
11-12-2006, 04:04 PM
can any of you advise me on the benefits of using relative over absolute, and vice versa. Or maybe refer me to a place I could read up on this subect?