View Full Version : local root webpage url paths issues

07-14-2008, 10:26 AM
I have a problem. I want to end up with only root path urls in my webpages(eg img src="/images/image.jpg") as opposed to relative paths(img src="../../images/image.jpg"). When browsing my site on the server once, I found lots of extra "///" characters in the address bar which I believe is because I used "../" in my url's, this is one of the reasons I want root paths. And also of course, if I change position of the page in the directory structure, I would have to change all relative paths.
So why cant I just use root paths? Simply becuase unless I upload it to my server, webpages will not display correctly on my computer becuase I cant set a root directory for my browsers.
Is there any software I can use to set a pseudo-server on my computer which will set a root directory for all browsers? Or are there any firefox/ie plugins that will accomplish this?
I was wondering how other designers deal with this issue. Right now I just manually edit the css style and image paths, links to other local pages I leave as root paths, which means I cant browser them unless I upload them to my server.
I will try writing a script to automatically change all "../../../" in my pages to just "/", which would solve the problem of editing relative to root, but I would still have all the other issues I mentioned above.
Any ideas are appreciated.

07-14-2008, 10:35 AM
I forgot to mention absolute paths, if I upload all files to my server I could use an absolute http path for all my links but I am not sure if it is good practice. And also no one would be able to browse the website offline.
Another question, which paths are best for SEO? Relative, Root, Absolute? Or does it not matter?

07-14-2008, 06:10 PM
IICR, "///" means it is a local file external to the web processing.

Do you have code we could look at?

Generally, you use relative paths ("/images/some.img") so that if you move the root somewhere, it's not affected. If you hard code the root, then you are bound to it.

07-14-2008, 09:14 PM
When I uploaded the files to my webhost, I had parent relative links starting with "../../" which caused the "///" in the url bar...... I have decided to use root links for everything "/images/image.jpg, /layout/styles.css", so if I move the files around, then I wont have to change the links.

Problem is, I can not view links starting with only "/" on my computer locally..... so I installed apache server, but I do not know how to set it up....

I have read apache docs.

I have entered document root:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
DocumentRoot "C:/operator1/oex-onmedias/primary"

So now apparently, when I type "http://www.onmedias.com/" in my browser, it would display C:/operator1/oex-onmedias/primary/index.html, but it does not work! Why?

Another question, how would I then be able to browse my actual website on my web host after I have uploaded it to my online server if the url is the same? it would only take me to the local server.

Last question, how would I set up multiple local websites on apache? Do I need to do a new apache install for each website? Or if not, how do I divide doc-root urls and domains of multiple sites in my config file?