There is a site.ru site on the local apache server and there is a page.php file and style.css.

They are located like this:

site.ru/page.php site.ru/css/style.css 

The link to style.css in the page.php file is as follows:

 css/style.css 

She works. But the link works well:

 ../css/style.css 

And a higher level of nesting also works. Although in theory it should not be so.

Actually this is the question. Why does this work?

  • What is the problem? The highest category available to the site is / , where your page.php file is located. Climb to the category above in theory will not do anything. And the first option works in a direct logic. - Telion
  • If you open the page.php in the browser - show the exact value of the address bar (the domain can be hidden if it is secret), otherwise I don’t really believe you - andreymal

1 answer 1

If you need to specify that the file to which you refer is in the parent folder, use the symbols .. (two dots), they mean to go up one level (to the parent folder of the current directory). Next we specify the forward slash "/" to separate the parts of the path, and write the name of our file.

Note : symbols .. you can use as many times as you like, using them, you go up one folder each time. However, you can climb up until you come to the root folder of your site. Above this folder can not rise.

A source

  • But the css folder is not in the parent folder - andreymal
  • @andreymal why is that? The parent folder includes the page.php file and the css/ category. - Telion
  • @Telion that's it, they are both in the same directory, and this parent directory is already current - so no ../ is needed - andreymal
  • @andreymal Oh, in that respect. That's right, access to the category above is not needed. But the question was why it works. - Telion
  • It seems to me that the author just misses something or doesn’t finish speaking , but I'm not sure yet - andreymal