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?
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?
Share Improve this question asked May 18, 2011 at 6:07 user494461user494461 3- Look at the file permissions and/or ownership, configuration of webserver, double check your file names, etc...Could be a lot of things. – sje397 Commented May 18, 2011 at 6:11
- because you have a permission problem? check your webserver configuration and make sure it's the same as your local host wrt access rights. – Mat Commented May 18, 2011 at 6:11
- It looks like the file is on readable. That is what 403 means.. Check if file has correct permissions and folders it is in is accessible. – enoyhs Commented May 18, 2011 at 6:12
3 Answers
Reset to default 1If 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 least755 [rwxr-xr-x]
),
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.
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.