Server unable to read htaccess file, denying acces

2020-05-12 11:29发布

I have created a simple app using AngularJS. When I tried to host that project in my website http://demo.gaurabdahal.com/recipefinder it shows the following error:

Forbidden

You don't have permission to access /recipefinder on this server. Server unable to read htaccess file, denying access to be safe

But if I go to http://demo.gaurabdahal.com/ it displays "access denied" message as expected, that I have printed. But why is it unable to open that AngularJS projects "recipefinder". If I tried to put a simple HTML app there, it opens just fine.

The same AngularJS project works fine when I host that in github (http://gaurabdahal.github.io/recipefinder)

I can't understand what's wrong.

11条回答
Anthone
2楼-- · 2020-05-12 11:45

In my case apache was somehow configured wrong so I had to set permissions to all parent dirs too. Just setting permission to .htaccess (and it's parent dir) didn't work.

查看更多
Juvenile、少年°
3楼-- · 2020-05-12 11:48

GoDaddy shared server solution

Basically, I had the same issue when trying to deploy separate Laravel project on a subdomain level.

File structure

- public_html (where the main web app resides)
    [works fine]

    - booking.mydomain.com (folder for separate Laravel project)
        [showing error 403 forbidden]

Solution

  1. go to cPanel of your GoDaddy account
  2. open File Manager
  3. browse to the folder that shows 403 forbidden error
  4. in the File Manager, right-click on the folder (in my case booking.mydomain.com)
  5. select Change Permissions
  6. select following checkboxes

    a) user - read, write, execute
    b) group - read, execute
    c) world - read, execute
    
    Permission code must display as 755
    
  7. Click change permissions

Job done!

查看更多
祖国的老花朵
4楼-- · 2020-05-12 11:56

Just my solution. I had extracted a file, had some minor changes, and got the error above. Deleted everything, uploaded and extracted again, and normal business.

查看更多
聊天终结者
5楼-- · 2020-05-12 11:58

You need to run these commands in /var/www/html/ or any other directory that your project is on:

sudo chgrp -R group ./
sudo chown -R user:group ./
find ./ -type d -exec chmod 755 -R {} \;
find ./ -type f -exec chmod 644 {} \;

In my case (apache web server) I use www-data for user and group

查看更多
姐就是有狂的资本
6楼-- · 2020-05-12 11:58

"Server unable to read htaccess file" means just that. Make sure that the permissions on your .htaccess file are world-readable.

查看更多
登录 后发表回答