How do i get the root path in html?

I'm writing a template for dreamweaver, and don't want to change the scripts for subfolder pages.

Is there a way to make the path relative to the root directory?

for example:


Instead of **root** above, I want a default path there. Is there any way to do anything like this?

How do i get the root path in html?

asked Apr 19, 2011 at 7:58

To be relative to the root directory, just start the URI with a /



answered Apr 19, 2011 at 8:01

QuentinQuentin

876k121 gold badges1172 silver badges1287 bronze badges

10

I recommend using the HTML element:


    
    
    

In this example, the stylesheet is located in http://www.example.com/default/style.css, the script in http://www.example.com/default/script.js. The advantage of over / is that it is more flexible. Your whole website can be located in a subdirectory of a domain, and you can easily alter the default directory of your website.

answered Mar 24, 2017 at 10:39

Alexander JankAlexander Jank

2,2201 gold badge16 silver badges19 bronze badges

2

/ means the root of the current drive;

./ means the current directory;

../ means the parent of the current directory.

How do i get the root path in html?

Huy Nguyen

2,0153 gold badges24 silver badges34 bronze badges

answered Dec 7, 2016 at 6:55

MistyDawnMistyDawn

7877 silver badges8 bronze badges

Just start it with a slash? This means root. As long as you're testing on a web server (e.g. localhost) and not a file system (e.g. C:) then that should be all you need to do.

answered Apr 19, 2011 at 8:01

Lee KowalkowskiLee Kowalkowski

11.5k3 gold badges38 silver badges45 bronze badges

7

This is oddly confusing to me. I know it shouldn't be. To check my understanding, I'd like to use a family relations model to compare. Assuming "You" is the current webpage, is the following correct?

How do i get the root path in html?
In your folder with you, like a sibling
How do i get the root path in html?
In your child's folder, under you
How do i get the root path in html?
In your parent's folder, above you
How do i get the root path in html?
In your cousin's folder

So, up to parent, over to sibling, down to their child = your cousin, named "images".

answered Jun 22, 2018 at 22:40

1

As Alexander Jank mentioned is great. When using sub-domains e.g. default.example.com base works great, because the JS and CSS loads from the said sub-domain and is accessible to both default.example.com and example.com/default

When using the root path, and your JS and CSS files are located in example.com/css, or example.com/js, then the subdomain has no access and the root of the subdomain is not accessible, except using the base.

How do i get the root path in html?

answered Feb 20, 2021 at 21:01

How do i get the root path in html?

Use two periods before /, example:

../style.css

How do i get the root path in html?

answered Aug 8, 2015 at 5:45

1

You can use ResolveUrl

" />

Rob

26.7k15 gold badges81 silver badges94 bronze badges

answered Dec 4, 2015 at 0:11

2

How do I find the root directory in html?

For the Grid, a website's root directory is the …/html folder. This is located in the file path /domains/example.com/html. The root directory can be viewed/accessed through File Manager, FTP, or SSH.

How do I find the root directory path?

In order to get the root directory path, you can use _DIR_ or dirname(). echo dirname(__FILE__); Both the above syntaxes will return the same result.

What is the root of my website?

The web root is the folder where the website files for a site are stored. Each site under your host gets an unique root folder. The root folder is placed under the sites username. Inside the web root folder you'll find folders like \logs , \public , \private and more.

What is a root file path?

What is a ROOT PATH ? The "root” path is where everything is stored and usually shows as / Eg: /documents/wakdev. pdf where the first / character is the root path. In the new version, you must define what directory tree you want to use as the root path.