您好,我在 /var/www/error_page/ 中创建了一个 error.html 文件,以便在出现 403 错误时显示此页面。
我的 /var/www/html/wordpress/.htaccess 文件看起来像这样
order allow,deny
allow from my_ip
ErrorDocument 403 /var/www/error_page/error.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
当我想从网络外部访问我的网站时,我得到的是这个页面,而不是我想要的页面
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.
Apache/2.4.59 (Debian) Server at example.com Port 443
提前感谢您的帮助
可能 apache 无权读取 error_page 目录,或者您需要在 error_page 目录中添加 .htaccess 文件,如下所示:
Require all granted