Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set relative path to current folder?

Tags:

html

Lets say I am currently at: http://example.com/folder/page.html

Is it possible to create a relative link on this page that points to http://example.com/folder/ without specifying folder anywhere? (And using only HTML.)

UPDATE: As it turned out ./ works only in non-strict doctype mode, while . works in both modes, so it is still a better answer in my opinion :) Thanks everybody.

like image 701
serg Avatar asked Nov 17 '08 20:11

serg


People also ask

How do you set a relative path?

Absolute and relative paths in script tools You can also set this option by right-clicking the script tool, clicking Properties, then clicking the General tab. At the bottom of the dialog box, check Store relative path names (instead of absolute paths).

How do I change a folder using relative path?

To change directories using absolute pathnames, type cd /directory/directory; to change directories using relative pathnames, type cd directory to move one directory below, cd directory/directory to move two directories below, etc.; to jump from anywhere on the filesystem to your login directory, type cd; to change to ...


2 Answers

Just dot is working. The doctype makes a difference however as sometimes the ./ is fine as well.

<a href=".">Link to this folder</a> 
like image 68
MrChrister Avatar answered Sep 17 '22 15:09

MrChrister


For anyone who has found this thread, addressing relative paths has always created arguments over what is correct or not.

Depending on where you use the path to be addressed, it will depend on how you address the path.

Generally :

. and ./ do the same thing, however you wouldn't use . with a file name. Otherwise you will have the browser requesting .filename.ext as a file from the server. The proper method would be ./filename.ext.

../ addresses the path up one level from the current folder. If you were in the path /cheese/crackers/yummy.html, and your link code asked for ../butter/spread.html in the document yummy.html, then you would be addressing the path /cheese/butter/spread.html, as far as the server was concerned.

/ will always address the root of the site.

like image 29
Mark Giblin Avatar answered Sep 20 '22 15:09

Mark Giblin