site root relative path

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
vchris
Forum Contributor
Posts: 204
Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec

site root relative path

Post by vchris »

Hey guys!

I have a site which I will have includes for the header and footer. There will be many levels of folders so the document relative path wouldn't work.

I'm using IIS for my development server. So I have the wwwroot folder in which I have all my websites and stuff... one folder is for that site. If I use this:

Code: Select all

<img src="/images/banner.jpg">
It will not find the banner.jpg image because it's not under the wwwroot folder its under wwwroot/mysite/images/banner.jpg

What I wanna know is, is there a way to change to root directory so I can use /images/image.jpg for my images and includes?

I know on the website server that's not an issue.

Can I configure IIS to change that or is there any other way?

my site is in php btw.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

I think putting this in your <head> does the trick

Code: Select all

<BASE href="http://www.example.com/mysite/">
vchris
Forum Contributor
Posts: 204
Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec

Post by vchris »

But I'm still on the dev server so I cannot refer to it as a .com or anything u know its http://localhost/mysite/index.php
vchris
Forum Contributor
Posts: 204
Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec

Post by vchris »

anyone?
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

try adding the port to localhost...

example

Code: Select all

<BASE href=http://localhost:80>
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Re: site root relative path

Post by raghavan20 »

vchris wrote:I have a site which I will have includes for the header and footer. There will be many levels of folders so the document relative path wouldn't work.
I am pretty sure that you will be able to refer to any document with relative path, provided the files are in the same drive.

use ../ for moving back
use / for moving forward
vchris
Forum Contributor
Posts: 204
Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec

Post by vchris »

what if I have a header.php file included in each page.

How would I link to the css file with relative path? The pages are on different levels so ../css/style.css wouldn't work for all pages.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

it seems like you do not want to give specific relative paths for all URLs. 8O
vchris
Forum Contributor
Posts: 204
Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec

Post by vchris »

No I don't. I want absolute path except on the dev server it won't work.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Re: site root relative path

Post by nickman013 »

raghavan20 wrote:
vchris wrote:I have a site which I will have includes for the header and footer. There will be many levels of folders so the document relative path wouldn't work.
I am pretty sure that you will be able to refer to any document with relative path, provided the files are in the same drive.

use ../ for moving back
use / for moving forward
on this, each . [dot] moves back a folder?
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Re: site root relative path

Post by raghavan20 »

nickman013 wrote:
raghavan20 wrote:
vchris wrote:I have a site which I will have includes for the header and footer. There will be many levels of folders so the document relative path wouldn't work.
I am pretty sure that you will be able to refer to any document with relative path, provided the files are in the same drive.

use ../ for moving back
use / for moving forward
on this, each . [dot] moves back a folder?
no two dots let you move a folder one level down....

If you can remember in Windows cd. is the same folder but cd.. takes you back to the folder one level down
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

o, ok thanks

if there a way to go back like 3 folders or somthing?
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

../../../current_directory...as simple as that ...one ../ for going back one level down.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

cool, thanks alot that really helps me
Post Reply