View Full Version : web path problem
charon
03-25-2003, 06:09 AM
hi,
I'm just curious to know, how most developer specify their image's SRC attribute or a tag's href atribute.
Just assume that we have a small new web-site with folders and files stated below:
Under the root directory inetpub\wwwroot\, there are folders and files:
default.asp
about.asp
profile.asp
imageFolder
pic.jpg
pic2.jpg
IncludeFolder
navigation.asp
connection.asp
Folder1
folder1
index.asp
file1.asp
file2.asp
file3.asp
folder2
index.asp
file1.asp
file2.asp
file3.asp
folder3
index.asp
file1.asp
file2.asp
file3.asp
Just assume that the index.asp of each folder has image SRC and href attribute point to the files under the wwwroot directory, how they specify it.
for me , i will use
image SRC="/imageFolder/pic.jpg"
href = "/IncludeFolder/navigation.asp"
href="/default.asp"
or
image SRC="../imageFolder/pic.jpg"
href = "../IncludeFolder/navigation.asp"
href="../default.asp"
Please advice!
david7777
03-25-2003, 07:46 AM
The relative path in your second example is what I use mostly (../images/pic.gif) - To use an absolute path (http://www.domain.com/images/pic.gif) all the time is crazy, because if you decide to change servers, you will have to go to EVERY url and image to change the path... And also, with absolute paths, you cant really test on your own computer because all the links go to a diffirent domain.
So its normally best to use relative paths, but there are cases when absolute paths are needed.
I have seen other posts on similar topics before - you should do a search...
charon
03-25-2003, 08:59 AM
But I'm sure if you use :
image SRC="/imageFolder/pic.jpg"
href = "/IncludeFolder/navigation.asp"
href="/default.asp"
Sould be no problem since starting with the slash means from the root directory, instead of like what you have
said, use ablolute path: -> http://www.domain.com/images/pic.gif
My problem is :
ok, I have a web-site which I create it under the wwwroot directory (inetpub/wwwroot), I don't have what we call it new web as in FrontPage and new web project in interdev. The web folder structure is as below:
inetpub/wwwroot/
default.asp
about.asp
feedback.asp..etc
IncludeFolder
connection.asp
navigation.asp
javafunction.js
ImageFolder
pic.jpg
pic2/jpg
folder1
index.asp
file1.asp
file2.asp
file3.asp
folder2
index.asp
file1.asp
file2.asp
file3.asp
folder3
index.asp
file1.asp
file2.asp
file3.asp
so, when I access the site via local machine, i just type :
localhost/
all the web pages (.asp) share a same navigation.asp file. For instance, in the folder1
index.asp, there is a statement <!-- #Include virtual="/include/navigation.asp" -->, as well as others .asp files.
(Previously, I didn't use Interdev) If I use the Interdev, create a new web project (new web application), then the virtual path of the new web project will be http://localhost/newproject/default.asp. The pysical path will be c:\inetpub\wwwroot\newproject\, So, if I add all the existing files and folders into this new project, then the link point to the <!-- #Include virtual="/include/navigation.asp" --> will be incorrect , I have to change it into
<!-- #Include virtual="/newproject/include/navigation.asp" --> . For the pages which have image SRC="/imageFolders/pic.jpg" will point to incorrect folder I have to change them into SRC="/newproject/imageFolder/pic.jog".
That is why I want to know if I use interdev and convert my existing web site into the web project, do i need to change the "path or SRC".
I must use Interdev for creating a web project is because i want to set a "multi authoting enviroment" by utilising VSS or FrontPage Source Control.
DO HOPE CAN GET RESPONSE FROM U.
david7777
03-25-2003, 09:57 AM
So basically you want to move your site to a new fo;der?
Ok - are you moving ALL your files to the new folder? Or are you still accessing files from the old location?
I think that in the case of the include, it might be one of those cases of needing to use an absolute url... I say this because if it is goind to be used by every page, and if some pages are in different directories, you will need absolute urls. ie: if index.asp is in the root, but pics.asp is in the images directory, then using a relative path wont work... indes.asp will link to "http://localhost/IncludeFolder/navigation.asp", while pics.asp will link to "http://localhost/images/IncludeFolder/navigation.asp".
So - use an absolute path. ie: "http://localhost/IncludeFolder/navigation.asp" in your include.
There might be a better way, but that is the best I can think of...
Why dont you just move all your old files to the new directory? Then you wont have to change any paths?
charon
03-25-2003, 10:25 AM
1.) I can say that if I use Interdev to Create a new web project, then add in the existing web-site, then it will consider move to new folder.
I'm using win2k profesional, if I use the inetpub/wwroot for my web-site (what I mean here is I put all the folders and files of the web-site in this root directory), the how can I create more than one web-site. So I have to change my
inetpub/wwwroot/
default.asp
about.asp
feedback.asp..etc
IncludeFolder
connection.asp
navigation.asp
javafunction.js
ImageFolder
pic.jpg
pic2/jpg
folder1
index.asp
file1.asp
file2.asp
file3.asp
folder2
index.asp
file1.asp
file2.asp
file3.asp
folder3
index.asp
file1.asp
file2.asp
file3.asp
to become:
inetpub/wwwroot/newweb1
default.asp
about.asp
feedback.asp..etc
IncludeFolder
connection.asp
navigation.asp
javafunction.js
ImageFolder
pic.jpg
pic2/jpg
folder1
index.asp
file1.asp
file2.asp
file3.asp
folder2
index.asp
file1.asp
file2.asp
file3.asp
folder3
index.asp
file1.asp
file2.asp
file3.asp
so that I create another new web as below:
inetpub/wwwroot/newweb2
default.asp
about.asp
feedback.asp..etc
IncludeFolder
connection.asp
navigation.asp
javafunction.js
ImageFolder
pic.jpg
pic2/jpg
folder1
index.asp
file1.asp
file2.asp
file3.asp
folder2
index.asp
file1.asp
file2.asp
file3.asp
folder3
index.asp
file1.asp
file2.asp
file3.asp
2.)I can't use obsolute path "http://localhost/IncludeFolder/navigation.asp" in my include. Once I upload to my production site, the absolute path will not correct -> "http://www.mysite.com/IncludeFolder/navigation.asp"
david7777
03-25-2003, 11:47 AM
Ok - Assuming that you want all your files and folders on the same server for the same site, you need to do the following:
Copy everything from the root folder (inetpub/wwwroot/) to the newweb1 folder. Actually - cut and paste. You dont want it duplicated, and dont need it in the root...
You shouldnt really use the root folder if you are creating more then one site - it creates hassles... So when ever you make a new site, put it in its appropriate folder. (newSite3 or something)
Now you will be able to use relative paths for your site.
So you will land up using the path "localhost/newweb1/" instead of just "localhost" in your browser when testing.
So you should have:
- inetPub
- wwwroot
+ newweb2
+ newweb3
+ newweb4
+ newweb5...etc
- newweb1
default.asp
about.asp
feedback.asp..etc
- IncludeFolder
connection.asp
navigation.asp
javafunction.js
- ImageFolder
pic.jpg
pic2/jpg
- folder1
index.asp
file1.asp
file2.asp
file3.asp
- folder2
index.asp
file1.asp
file2.asp
file3.asp
- folder3
index.asp
file1.asp
file2.asp
file3.asp
whammy
03-26-2003, 12:37 AM
Why don't you use include virtual?
You can use it anywhere on your site, using the root, like:
<!-- #include virtual="/subdirectory/subdirectory/filename.ext" -->
the forward slash "/" I highlighted would stand for the root directory itself. ;-)
P.S. I often use this same format (i.e. "/images/wow.gif") for just referencing files in HTML and/or javascript, and it works fine, if I remember right. ;-)
charon
03-26-2003, 01:49 AM
David 777, ya, what you have explained actually is exactly same as what I have explained in my previous post.
If I want to create multi web-site, I shouldnt really use the root folder, it will creates hassles. So, if i create
multi web-sites, my local's web structure will look like as you said.
- inetPub
- wwwroot
+ newweb2
+ newweb3
+ newweb4
+ newweb5...etc
- newweb1
default.asp
about.asp
feedback.asp..etc
- IncludeFolder
connection.asp
navigation.asp
javafunction.js
- ImageFolder
pic.jpg
pic2/jpg
- folder1
index.asp
file1.asp
file2.asp
file3.asp
- folder2
index.asp
file1.asp
file2.asp
file3.asp
- folder3
index.asp
file1.asp
file2.asp
file3.asp
BUT, MY PROBLEM IS : since I use "Start with Slash( <!-- #Include virtual="/includeFolder/navigation.asp" -->), for all the LINK
So, that is why I'm asking, DO I NEED TO CHANGE ALL THE PAGES' LINK to become not start with slash? as below:
1.) <!-- #Include virtual="includeFolder/navigation.asp" --> if the file point to the navigation.asp is within the same "directory"
i.e: inetpub\wwwroot\newproject
default.asp (file has include navigation.asp)
includeFolder
-navigation.asp
2.) <!-- #Include virtual="../includeFolder/navigation.asp" --> if the file point to the navigation.asp is in the subfolder of the newproject's folder
i.e: inetpub\wwwroot\newproject2
default.asp
Folder1
-index.asp (file has include navigation.asp
includeFolder
-navigation.asp
Whammy, I know the virtual path, and i mostly use it, but I'm now facing problem. My situation not allow me to use it, why??
My web-sites are hosting at ISP web server, and the root directory structure is as below:
web (root directory)
default.asp
about.asp
feedback.asp..etc
folder1
folder2
folder3
so, in order for me to run the web site in my staging site and also the production site without changing the "LINK"
the web structure between these two must same.
If i use include virtual as you said <!-- #include virtual="/subdirectory/subdirectory/filename.ext" --> after I move the site to my production server (ISP web server), all the Link will be incorrect.
why?? because if I have multi web sites and my local web structure is as below:
- inetPub
- wwwroot
+ newweb2
+ newweb3
+ newweb4
+ newweb5...etc
- newweb1
default.asp
about.asp
feedback.asp..etc
- IncludeFolder
connection.asp
navigation.asp
javafunction.js
- ImageFolder
pic.jpg
pic2/jpg
- folder1
index.asp
file1.asp
file2.asp
file3.asp
- folder2
index.asp
file1.asp
file2.asp
file3.asp
- folder3
index.asp
file1.asp
file2.asp
file3.asp
I must specify my include virtual link as <!-- #include virtual="/newweb1/includeFolder/filename.ext" -->
But, when I upload to the production site, the correct link is <!-- #include virtual="/includeFolder/filename.ext" -->
david7777
03-26-2003, 06:45 AM
Aaahaa! *glowing bulb above head*
Ok - I see what you are saying... :o
Uhhh... How do I say this nicely - You're stuffed.
No no - just kidding... :D
I havent really played around with IIS much, but cant you save the web files under "my documents" or something (non web-folder), and then create a virual directory using the IIS? I havent tried it so it might give the same problems...
Otherwise you might have to move all the files back to the wwwroot folder and change you working folder for InterDev to the root. This will mean that you can only have one web site with this sort of relative pathing...
So just copy everything back to your root and open the files from there.
Unless of course, someone has a better way?
charon
03-26-2003, 07:59 AM
haha, this time guess I need to give you "Consultancy" alreday.
I havent really played around with IIS much, but cant you save the web files under "my documents" or something (non web-folder), and then create a virual directory using the IIS? I havent tried it so it might give the same problems...
Same problem, by create Virtual Directory under C , the virtual path is http://localhost/newwebdir/, so same problem accur....
Otherwise you might have to move all the files back to the wwwroot folder and change you working folder for InterDev to the root. This will mean that you can only have one web site with this sort of relative pathing... >>So just copy everything back to your root and open the files from there.
Cannot, in order to use source control for the interdev web peoject, first of all we must create a web project. When the web project is create, the virtual path sure as below:
http://localhost/newwebdir/
and the pysical path will be c:\inetpub\wwwroot\newweb1
GUESS I NEED TO SPEND MY TIME ON CHANGING THE LINK :((
Whammy, what do you think
glenngv
03-26-2003, 08:59 AM
if i correctly followed the long discussion...
create another virtual directory, say testenv (test environment) that points to the new project
inetpub\wwwroot\newproject
so that when testing the pages in the browser, you will specify:
http://localhost/testenv/default.asp
in that way, you can make your links and include files always start at the root.
e. g. <!-- #Include virtual="/includeFolder/navigation.asp" -->
david7777
03-26-2003, 09:25 AM
Cannot, in order to use source control for the interdev web project, first of all we must create a web project. When the web project is create, the virtual path sure as below:
http://localhost/newwebdir/
and the pysical path will be c:\inetpub\wwwroot\newweb1
GUESS I NEED TO SPEND MY TIME ON CHANGING THE LINK (
You give up too easily...
Im 99% sure you can do it. I havent used InterDev, but if it is working with virtual paths, then there is a setting to where it will point. There are also InterDev project settings somewhere that can be changed or mannipulated...
So - you need to copy all your data to the root. then you need to go to IIS settings and redirect the path to the root. (c:\inetpub\wwwroot\)
Then you need to open the project from the root, or change the settings in InterDev to read from the root.
I know InterDev automatically creates the project directory, but if you move it, it should still work as normal...
charon
03-26-2003, 12:09 PM
I really can't get solution, that is why I post my problem here....
hope someone can help.
So - you need to copy all your data to the root. then you need to go to IIS settings and redirect the path to the root. (c:\inetpub\wwwroot\)
Then you need to open the project from the root, or change the settings in InterDev to read from the root. I know InterDev automatically creates the project directory, but if you move it, it should still work as normal...
I don't have idea how to change it, moreover never hear about it.
and I want my wwwrrot directory look as below:
inetpub\wwwroot\
newweb1
newweb2
newweb3
easier to maintain multi web-sites
I don't understand glenngv's post. Can elaborate more.....
david7777
03-26-2003, 12:23 PM
I think that glenngv was saying what i said in one of my earlier posts about creating a virtual directory and putting you files in another directory like my documents...
If you want to keep your site structure neat:
inetpub\wwwroot\
newweb1
newweb2
newweb3
then you will have to go and change all the links...
Or, just for the purpose of testing on your computer, make a copy of the include, and put it in the root folder, so that you can still use relative paths to the root. ie: you will use "<!-- #Include virtual="/includeFolder/navigation.asp" -->". It will point to c:\inetpub\wwwroot\includeFolder\navigation.asp, so that is where you must put a copy of the file. Just make sure to upload the correct file when uploading the site... Its a bit of a hassle having duplicates of files, but I think its your best option in this situation...
whammy
03-27-2003, 12:21 AM
For that website, I think you can change the home directory in IIS - I don't have it installed on this computer, but I'm about 99% sure you can do it too...
charon
03-27-2003, 06:53 AM
1.) yup, wammy, we can change the Default web site's home directory (via IIS) from c:\inetpub\wwwroot\ to any other directory, i.e c:\newweb, so i think in order for me to create a web project at Interdev for my existing web-site without changing all the URL/Link-> is to set the default web site's home directory, well, it is really easy.
2.) But, if like this it only allow me to create a Default Web Site which all the link can start with slash. For the second and third web site I must use relative path as we have disccussed so far. CORRECT???
3.)when we start a link with slash, i.e <a href="/dir/file,asp">, <img SRC="/images.jpg">, it is consider absolute path.
i'm here have a question, I found that when we create our link as above (start with slash), it has two meaning,
1.) Start from root directory of the webs-site
2.) Start from a Virtual Directory call /dir
If the situation is 2, then it might point to wrong location.
Please advice.
whammy
03-27-2003, 11:40 PM
Hmm, I'm not completely sure what you're getting at - but if you need to get a local path, just use Server.MapPath() ;)
charon
03-28-2003, 02:45 AM
Hi,
after a big trial, now only i realize my "problem" which we has been discussing actually is not a problem. I still be able to use interdev for source control purpose without "Create a New Application", but connect to an existing web application on localhost (as I said, my current web site is located on the wwwroot directory).
So, from now onward, I will use relative path for me new web application.
Thanks for spending so much time with.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.