简体   繁体   中英

serving static files

Previously I was working on one django project under the domain of abc.com and serving static media files under abc.com/media/. But I realized it would be better to separate my task into 3 different django projects under the subdomains user1.abc.com user2.abc.com and abc.com.

my question is, what is the best way to serve the static files(css,js) now?

Should I create separate folders for each site and have separate urls pointing to there?

Or should I keep store all the files in one url? If so, does it means I cannot use relative path in the url() of my css files?

You can either use "static.abc.com" and put everything in there, but then you have to use absolute urls in your css files, or you may be able to make use of (depending on your web host) a symlink to the shared directory, and serve the static files using nginx/apache. eg:

/app/user1/media -> /path/to/static/files
/app/user2/media -> /path/to/static/files

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