Cannot access javascript folder
Solution 1
Ubuntu Apache configuration already has Alias /javascript /usr/share/javascript/
, see /etc/apache2/conf.d/javascript-common.conf. You could change this alias or remove this file altogether but I don't know if this breaks something else.
Solution 2
The issue:
Web applications that use JavaScript need to distribute it through HTTP. Using a common path for every script avoids the need to enable this path in the HTTP server for every package.
This is the package that creates /usr/share/javascript
alias and enables it in the Apache webserver.
Recommended fix
And that's it, you won't have any other problem with javascript directories. Another fix could be to rename /usr/share/javascript/
to /usr/share/javascript-common/
, then adjust the Alias in javascript-common.conf
to point to the renamed dir. Still not sure if this will affect any future update.
Another Fix:
Go to /etc/apache2/conf-available/javascript-common.conf
, you will find this:
Alias /javascript /usr/share/javascript/
<Directory "/usr/share/javascript/">
Options FollowSymLinks MultiViews
</Directory>
So you just have to comment this lines (with the #
char) (is not recommend to edit directly the file in conf-enabled) to avoid the forbidden error. After that, do this:
a2disconf javascript-common
a2enconf javascript-common
Solution 3
Apache has an option called 'DirectoryIndexes', when you visit a raw path to a folder without an index document (index.html,index.php etc.) it will display a list of files and folders in that directory like a normal file browser. However if DirectoryIndexes is disabled it will throw a 403 (Access denied) error when it tries to show the folder.
Create a .htaccess file in the /javascript/ directory with the following
Options +Indexes
And try looking at the directory again, you should then get a list of all the files in the directory.
Related videos on Youtube
John Burke
Updated on September 18, 2022Comments
-
John Burke almost 2 years
I signed up and setup a small ubuntu VPS slice during the week and everything is going great so far, except one small problem.
I have two virtual hosts setup but cannot access the javascript folder for each. If i navigate to www.domain1.com/javascript or www.domain2.com/javascript i get the following message...
You don't have permission to access /javascript/ on this server.
If I rename the directory to anything else (eg: js) I can access the contents no problem. It seems to be a reserved keyword or something, even without a javascript folder i get the same message rather than a 404 message.
I removed the .htaccess files just incase that was causing it. Nope... Any idea whats going on here?
-
AlexD about 13 yearsAccess defined is 403. >500 errors range is for internal server errors.
-
Toby Mao about 13 years@AlexD Yeah sorry about that =) I wrote that answer at 1AM this morning
-
Toby Mao about 13 yearsDoes it? Wow I never knew that, probably cuz most of our servers are RHEL but is there any reason why they have this? Is it to hold standard library's like jQuery etc. or does it serve some other purpose?
-
AlexD about 13 yearsYes, under ubuntu /usr/share/javascript/ contains jQuery & Prototype libraries provided by
libjs-jquery
&libjs-prototype
packages. -
John Burke about 13 yearsThanks man, that fixed it... Was that an extra package i installed or is apache setup like that?
-
AlexD about 13 yearsAFAIK, this is default Apache configuration under Ubuntu.
-
Tomás Ramírez almost 10 yearsI have been like 5 hours changing permissions and setting things, crazy apache! o.O