It seems to be a very beginner question, but after finish my whole website, i found a “bug” on the structure of the path files/images and links.
Well, first let me tell you what is the exactly structure:
The website are located on: /var/www
Main pages files are located on the main website folder: /www
CSS files are located at /www/styles/
JS Files on /www/js/
Images on /www/images/
I have been writing my path of files/images with this current directory:
JS: <script src="js/scripts.js"></script>
Image: <img src="images/img.jpg">
Links: if i was point to the same file with get parameter, i just writed: <a href="?parameter=test">
Links for others files: <a href="otherFile.php">
Well, like i said, after some time i found a “bug”. If i put / after .php link, for example: example.com/test.php/
, all my images/js/css files break and all the href links become: example.com/test.php/linkpage.php
instaed of example.com/linkpage.php
.
So, i have now to change all my images/files and links with “/” in the beginning, to avoid this bug, like:
<a href="/linktopage.php">
It seems to fix the problem, but its the correct way to path these things? I appreciate your help, thanks.
Advertisement
Answer
use / before links like: /otherFile.php /images/img.jpg
this “/” load from www
and your work is correct