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

  • 7,000
  • Tác giả: admin
  • Ngày đăng:
  • Lượt xem: 7
  • Tình trạng: Còn hàng

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

Assuming you have SSH access to tát the server (you have to tát enable it on cPanel), login to tát your tài khoản. Upon successful login, you will be placed in the trang chính directory for your tài khoản. The DocumentRoot for your trang web is located in a subdirectory named public_html. GoDaddy defaults the permissions for this directory to tát 750, but those permissions are inadequate to tát allow Apache to tát read the files for trang web. You need to tát change the permissions for this directory to tát 755 (chmod 755 public_html).

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

Next, make sure all of the files under public_html are world readable. To bởi 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 tát have a .htaccess tệp tin in the public_html tệp tin. GoDaddy enforces a rule that prohibits the site for loading if you bởi not have a .htaccess tệp tin in your public_html directory. You can use vi to tát create this tệp tin ("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 tệp tin (ZZ), and then make sure the tệp tin has permissions of 644:

chmod 644 .htaccess

Works lượt thích a charm.