astralaaron Posted December 2, 2007 Share Posted December 2, 2007 I use WAMP5, when I make a website to make the links work I have been writing them like this:<a href="http://localhost/website/file.html">click</a>I did not realize how big the website was going to turn out and there are lots of links... now when I put the website online..i have to change all the links..i know there has to be an easy way to write the links so you dont have to redue everyone of them when you put the website online..<a href="/file.html">click</a> i tried writing the same link like this and opening it in WAMP but it doesn't open the page..can anyone educate me on this? so I don't do something stupid like this in the future? Link to comment Share on other sites More sharing options...
Synook Posted December 2, 2007 Share Posted December 2, 2007 Well, say your folder had two pages index.html and file.html, to link to file.html from index.html you could have <a href="file.html">click</a> For subfolders, just put the folder / file. So if file.html was in a folder myfiles that resided in the same directory index.html you could link to it from index.html like so <a href="myfiles/file.html">click</a> If you had that structure, you could also link to index.html from file.html like so <a href="../index.html">click</a> Link to comment Share on other sites More sharing options...
jesh Posted December 3, 2007 Share Posted December 3, 2007 Keep in mind also that "/file.html" is telling the browser to look for the file called "file.html" in the root directory of the website.So, regardless of whether your page was at http://localhost/sub1/sub2/sub3/test.html or http://localhost/test.html, if you linked to "/file.html", the request would go out to http://localhost/file.html.If you only want to go up a single directory, you can use the ../ that Synook suggested. Link to comment Share on other sites More sharing options...
astralaaron Posted December 4, 2007 Author Share Posted December 4, 2007 Keep in mind also that "/file.html" is telling the browser to look for the file called "file.html" in the root directory of the website.So, regardless of whether your page was at http://localhost/sub1/sub2/sub3/test.html or http://localhost/test.html, if you linked to "/file.html", the request would go out to http://localhost/file.html.If you only want to go up a single directory, you can use the ../ that Synook suggested.i think you answered the question I was about to askif i wasnt in the root folder anymoresaywww.website.com/pictures/wilderness/trees.htmland i wanted to link back to a file in the root directory.. would i just write the link <a href="/page.html"></a> ?? Link to comment Share on other sites More sharing options...
Synook Posted December 4, 2007 Share Posted December 4, 2007 Try <a href="./page.html"></a> Link to comment Share on other sites More sharing options...
boen_robot Posted December 4, 2007 Share Posted December 4, 2007 i think you answered the question I was about to askif i wasnt in the root folder anymoresaywww.website.com/pictures/wilderness/trees.htmland i wanted to link back to a file in the root directory.. would i just write the link <a href="/page.html"></a> ??Yes.Try<a href="./page.html"></a> Isn't "./page.html" equivalent to "page.html"? Link to comment Share on other sites More sharing options...
Synook Posted December 5, 2007 Share Posted December 5, 2007 Hmm you are right. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.