How to go up a level in the src path of a URL in HTML?

后端 未结 6 1271
北荒
北荒 2020-11-28 02:06

I am storing style sheets in {root}/styles while images in {root}/images for a website. How do I give the path in the style sheets to go look in the images directory for th

6条回答
  •  失恋的感觉
    2020-11-28 02:52

    If you store stylesheets/images in a folder so that multiple websites can use them, or you want to re-use the same files on another site on the same server, I have found that my browser/Apache does not allow me to go to any parent folder above the website root URL. This seems obvious for security reasons - one should not be able to browse around on the server any place other than the specified web folders.

    Eg. does not work: www.mywebsite.com/../images

    As a workaround, I use Symlinks:

    Go to the directory of www.mywebsite.com Run the command ln -s ../images images

    Now www.mywebsite.com/images will point to www.mywebsite.com/../images

提交回复
热议问题