How can I put my JS and CSS files outside the public folder? I have a library that I’d like all my websites to use and for easy updating, have this outside a particular website public folder so it can be easily read by all. Is this possible or do I need to host it all on another domain (I’d rather not for ease).
htaccess possibly?
To properly expand on Jamie Wong’s response:
You can easily do this using a PHP file acting as a controller – but you must also remember to send the correct content headers otherwise the browser might not recognised the CSS for what it is.
You also need a bit of security checks to make sure there’s no file traversal
You can go further than this, and set up .htaccess rewrites to map CSS requests like /css/main.css to this controller: