How to fix the 403 forbidden error: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
Line 12: Line 12:
</pre>
</pre>


== Troubleshooting process ==
== Troubleshooting process of the 403 forbidden error ==
=== Client side: Check the permission ===


=== Check the SELinux policy if SELinux was enabled ===
# Check the cookie was enabled
 
=== Server side: Check the SELinux policy if SELinux was enabled ===


The result of {{kbd | key=<nowiki>ls -Zd</nowiki>}} should contains "httpd_sys_content_t:"
The result of {{kbd | key=<nowiki>ls -Zd</nowiki>}} should contains "httpd_sys_content_t:"
Line 23: Line 26:
</pre>
</pre>


=== Check the configuration of HTTP server ===
=== Server side: Check the configuration of HTTP server ===


Check if home directory exists e.g. {{kbd | key=<nowiki>/path/to/website/</nowiki>}} in the configuration of HTTP server. The folder location of configuration files maybe located on {{kdb | key=<nowiki>/etc/httpd/sites-enabled/</nowiki>}} depends on the HTTP server environment.
Check if home directory exists e.g. {{kbd | key=<nowiki>/path/to/website/</nowiki>}} in the configuration of HTTP server. The folder location of configuration files maybe located on {{kdb | key=<nowiki>/etc/httpd/sites-enabled/</nowiki>}} depends on the HTTP server environment.
Line 33: Line 36:
</pre>
</pre>


=== Check the syntax of .htaccess ===
=== Server side: Check the syntax of .htaccess ===


Check if the syntax of .htaccess ({{kbd | key=<nowiki>/path/to/website/.htaccess</nowiki>}} ) correct.
Check if the syntax of .htaccess ({{kbd | key=<nowiki>/path/to/website/.htaccess</nowiki>}} ) correct.

Revision as of 10:43, 9 December 2024

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