开发者

Json file gives 403 error on server

I have a json file contianing data which I access through java开发者_运维技巧script. 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?


If your production server is Linux based then please consider these:

  1. 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.

  2. 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] ),


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜