April 3, 201313 yr I have all the pages on my website stored in different folders. All the folders are in a main folder called "website", and there are subfolders inside that folder, below are a few examples of where web pages are stored. website>index.html website>pages>placestostay>citycentre>hotels.html website>pages>thingstodo>citycentre>shopping.html I have found out on other websites about adding the "/" before a file name or path. So to try it out I tried adding a link to the home page on the "hotels.html" page, as shown above. This is the code I put in: <a href="/index.html>Home</a> This doesn't work, but I found out by experimenting that it works if I type it like this: <a href="/users/daniel/desktop/website/index.html">Home</a> This works, but I realise that it will stop working once I upload it to the internet because it will be linking to the file on my computer (which of course it won't be able to find once it is uploaded to the internet). Is there anything else I can do, or is my only option using the "../../" tags to jump back one folder at a time, such as: <a href="../../../index.html">Home</a> Thank you for any help.
April 3, 201313 yr You also have a third option, "./" looks in the current directory. "../" -> Parent directory. "./" -> Current directory. "/" -> Absolute path. Léon
April 3, 201313 yr Author You also have a third option, "./" looks in the current directory. "../" -> Parent directory. "./" -> Current directory. "/" -> Absolute path. Léon Thank you for your help. I think I'm doing something wrong with this because I'm getting the following error "Internet explorer cannot display the webpage". This is the code I've typed: <a href="./index.html">Home</a> What am I doing wrong? Thank you for any help.
April 3, 201313 yr I have all the pages on my website stored in different folders. All the folders are in a main folder called "website", and there are subfolders inside that folder, below are a few examples of where web pages are stored. website>index.html website>pages>placestostay>citycentre>hotels.html website>pages>thingstodo>citycentre>shopping.html I have found out on other websites about adding the "/" before a file name or path. So to try it out I tried adding a link to the home page on the "hotels.html" page, as shown above. This is the code I put in: <a href="/index.html>Home</a> This doesn't work, but I found out by experimenting that it works if I type it like this: <a href="/users/daniel/desktop/website/index.html">Home</a> This works, but I realise that it will stop working once I upload it to the internet because it will be linking to the file on my computer (which of course it won't be able to find once it is uploaded to the internet). Is there anything else I can do, or is my only option using the "../../" tags to jump back one folder at a time, such as: <a href="../../../index.html">Home</a> Thank you for any help. Look at your first way you've done the link missing the " at the end
April 4, 201313 yr Remember that urls starting with / only work from your root directory, which means that it won't work on your computer from a local file as the root is normally C:\ with lots of other sub-folders and your index.html file won't be in your C:\ folder but in some other sub-folder. Go back to <a href="/index.html">Home</a> with the " after html and upload and check the online version. The code means that from any page at any level of subdirectory the link will be to your root (top level) directory which is where your index.html homepage normally is. You can get root-relative links working from a local file if you install WampServer 2 or XAMPP which include Apache server and you put your whole website inside the folder controlled by Apache inside WampServer or XAMPP but it is a bit complicated, so test online for the time being. Edited April 4, 201313 yr by Wickham
April 4, 201313 yr You can get root-relative links working from a local file if you install WampServer 2 or XAMPP which include Apache server and you put your whole website inside the folder controlled by Apache inside WampServer or XAMPP but it is a bit complicated, so test online for the time being. What Wickham said here is the best advice imo. and Xampp isnt that complicated. just install Xampp, open the control panel, run apache, and if you need it the mysql. Drop your website in a new folder in the htdocs folder inside the installation folder of xampp. go to http:/localhost/whateveryounamedyourwebsitefolder and then you're practically working online without the hassle of continuously uploading stuff. And then when you're done, you can just upload all your files from the htdocs folder to your host, perhaps export your mysql database. and you're done! I would really recommend doing this, since you're making things easier for yourself. otherwise you're doing double work, first developping for desktop, and then converting it to web.
April 4, 201313 yr Author Remember that urls starting with / only work from your root directory, which means that it won't work on your computer from a local file as the root is normally C:\ with lots of other sub-folders and your index.html file won't be in your C:\ folder but in some other sub-folder. Go back to <a href="/index.html">Home</a> with the " after html and upload and check the online version. The code means that from any page at any level of subdirectory the link will be to your root (top level) directory which is where your index.html homepage normally is. You can get root-relative links working from a local file if you install WampServer 2 or XAMPP which include Apache server and you put your whole website inside the folder controlled by Apache inside WampServer or XAMPP but it is a bit complicated, so test online for the time being. Thank you for your help, that works OK now.
Create an account or sign in to comment