简体   繁体   中英

Is there a way to link an external library from outside the project directory?

I have a jquery library in my project but need to put it in linux /usr/share/js directory and not inside of my project directory.

Is there a way to do a linking in the index.html?

Including in the index.html:

   <script src="/usr/share/js/jquery.min.js"></script>      

doesn't help, as it looks into my working dir and I don't have a 'usr' dir

/usr/share is in the root directory and not in my working one. I don't use any php or the stuff, is there a simple way to solve this?

You need to back out of the file you are currently in by using the ../ command which goes back one directory. Depending on how many files deep the index.html file is in your project, you may need more then one like so:

<script src="../../../../usr/share/js/jquery.min.js"></script>

This will direct you 4 files out of where your index.html file is located, you may need more or less depending just do some searching through your directories and adjust accordingly.

You can create symlinks for files like this, to allow access to serve from not your document root. The web server is also needs to be configured to follow symlinks when serving.

More info for Apache: http://httpd.apache.org/docs/2.4/urlmapping.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM