Reputation:
I have a json file contianing data which I access through javascript. On my virtual MAMP server on mac It works, but on my online server when I load the HTML file I cant access the json file from javascript. I get 403 no permission for access error. Why?
Upvotes: 2
Views: 9839
Reputation: 11
I also had this problem. I noticed in my apache2.conf file there is the following:
<Files ~ "\.(env|json|md|gitignore|gitattributes|lock)$">
Order allow,deny
Deny from all
</Files>
That's why it's blocked.
To allow access you need to remove the json
from there.
Upvotes: 1
Reputation: 580
I just realised that I was getting the same issue because my system.webServer had handlers for ServiceStack to capture all content:
<handlers><add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /></handlers>
But I also had added staticContent to deliver the JSON file extension (Windows8 IIS):
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/javascript" /></staticContent>
When i removed the staticContent, i was getting a 403 error.. but when I add it in, the ServiceStack handler overrides and triggers a 500... perhaps you have something similar? Make sure your config is set up to handle the mimetype.
Upvotes: 1
Reputation: 10327
If your production server is Linux based then please consider these:
please check the directory your file is inside. There must be a .htaccess file there, which contains settings regarding directory access. If this is the case, you'll have to either move the json file out of that directory, or disable the .htaccess settings in question.
Also, in some cases, you get this error when the file is unreadable for any reason:
a. file system errors - run fsck;
b. check file permissions, the file should have at least 644 [rw-r--r--]
, the directory the json file is inside of, should have at least 755 [rwxr-xr-x]
),
Upvotes: 1