How to fix the 403 forbidden error

From LemonWiki共筆
Jump to navigation Jump to search

How to fix the 403 forbidden error

Error message

When I tried to browse the website, I met the following message:

Forbidden
You don't have permission to access this resource.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Troubleshooting process of the 403 forbidden error

Client side: Check the permission

  1. Check the cookie was enabled

Server side: Check the SELinux policy if SELinux was enabled

The result of ls -Zd should contains "httpd_sys_content_t:"

$ ls -Zd /path/to/website/
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 /path/to/website/

Server side: Check the configuration of HTTP server

Check if home directory exists e.g. /path/to/website/ in the configuration of HTTP server. The folder location of configuration files maybe located on Template:Kdb depends on the HTTP server environment.

  <Directory /path/to/website/>
  ..
  </Directory>

Server side: Check the syntax of .htaccess

Check if the syntax of .htaccess (/path/to/website/.htaccess ) correct.

Example content of log

/path/to/website/.htaccess: Invalid command 'Force', perhaps misspelled or defined by a module not included in the server configuration, referer: http://mywebsite.com.tw/favicon.ico

Root cause: the original syntax was written for another version of HTTP server.

= More detail on HTTP server log

Log files maybe located on Template:Kdb

References