Server unable to read htaccess file, denying access to be safe

前端 未结 14 2836
情深已故
情深已故 2020-12-12 20:15

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:

14条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 20:39

    This is a common problem with GoDaddy virtual server hosting when you bring up a new website.

    Assuming you have SSH access to the server (you have to enable it on cPanel), login to your account. Upon successful login, you will be placed in the home directory for your account. The DocumentRoot for your website is located in a subdirectory named public_html. GoDaddy defaults the permissions for this directory to 750, but those permissions are inadequate to allow Apache to read the files for website. You need to change the permissions for this directory to 755 (chmod 755 public_html).

    Copy the files for your website into the public_html directory (both scp and rsync work for copying files to a GoDaddy Linux server).

    Next, make sure all of the files under public_html are world readable. To do this, use this command:

    cd public_html
    chmod -R o+r *
    

    If you have other subdirectories (like css, js, and img), make sure they are world accessible by enabling both read and execute for world access:

    chmod o+rx css
    chmod o+rx img
    chmod o+rx js
    

    Last, you will need to have a .htaccess file in the public_html file. GoDaddy enforces a rule that prohibits the site for loading if you do not have a .htaccess file in your public_html directory. You can use vi to create this file ("vi .htaccess"). Enter the following lines in the file:

    Order allow,deny
    Allow from all
    Require all granted
    

    This config will work for both Apache 2.2 and Apache 2.4. Save the file (ZZ), and then make sure the file has permissions of 644:

    chmod 644 .htaccess
    

    Works like a charm.

提交回复
热议问题