Shadin
Shadin

Reputation: 1967

access js from outside root folder

using apache web server and javascript/php webpage, is there ANY WAY to include javascript exist outside the root as a script in the index (html file) ?

Upvotes: 0

Views: 2999

Answers (3)

Musa
Musa

Reputation: 97672

The client only have access to files made available by the server, you can make directories outside of the document root available with alias

Alias /js /path/to/js
<Directory "/path/to/js">
    Require all granted
</Directory>

(I'm not to sure about the Require all granted part, but without it I get access denied)
Then you can access the /js folder form example.com/js

Upvotes: 1

Naftali
Naftali

Reputation: 146300

You can only include files which are publicly available.

Upvotes: 1

Jonathan M
Jonathan M

Reputation: 17451

Javascript, via the <script type="text/javascript" src="myurl"> can be included from anywhere. The browser takes it all in, regardless of the source.

Off-topic P.S.: That's why jsonp works for cross-domain requests.

EDIT: Your question's a bit ambiguous, but reading @Neal's answer, I think he's likely addressing what you meant to ask.

Upvotes: 0

Related Questions