Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何在不重定向到其他页面的情况下处理403错误_.htaccess_Error Handling_Http Status Code 403 - Fatal编程技术网

.htaccess 如何在不重定向到其他页面的情况下处理403错误

.htaccess 如何在不重定向到其他页面的情况下处理403错误,.htaccess,error-handling,http-status-code-403,.htaccess,Error Handling,Http Status Code 403,我的htaccess文件当前处理404错误,如下所示: Options +MultiViews Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ 404.html [L] 我没有使用ErrorDocument,因为它会重定向到绝对错误路径 我想保持相同的url,但显示403的自定义

我的htaccess文件当前处理404错误,如下所示:

Options +MultiViews
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ 404.html [L]
我没有使用
ErrorDocument
,因为它会重定向到绝对错误路径

我想保持相同的url,但显示403的自定义模板。目前403显示apache的默认错误页。。。我想在这里也显示一个自定义错误文档

我该怎么做


谢谢你的帮助;)

您可以使用带有相对目标路径的
ErrorDocument
。使用相对路径
ErrorDocument
指令不会重定向请求,而是在不更改url的情况下显示错误页面

ErrorDocument 403 /403.php