gpt4 book ai didi

file - .htaccess |您是否必须在每个目录中为每个错误安装htaccess,还是在根目录中仅安装一个?

转载 作者:行者123 更新时间:2023-12-03 07:50:32 25 4
gpt4 key购买 nike

具有以下结构:

Root/ dir1/ dir2/ dir3/ dir4/dir5/ dirN...

假设我想通过 Forbid访问 dir4/

我将把 .htaccess文件放在哪里?在该 dir4/中还是在 root/中?

要么

假设某人链接到 dir5/page3.php,并且页面上显示 not exist,如果我希望将他们重定向到 404.html文件... .htaccess是否必须已安装在 dir5/中,还是足以在 root文件夹中安装它?

因此,一般而言, .htaccess文件应该在哪里?

1)每个文件夹?要么

2)在 root/主目录中只有一个?

请帮助thanx

最佳答案

我猜你在说什么叫做..

服务器响应代码

A server reponse code is a three digit number sent by a server to a user in response to a request for a web page or document. They tell the user whether the request can be completed, or if the server needs more information, or if the server cannot complete the request. Usually, these codes are sent 'silently' - so you never see them, as a user - however, there are some common ones that you may wish to set up error pages for, and they are listed below. Most people will only ever need to set up error pages for server codes 400, 401, 403, 404 and 500, and you would be wise to always have an error document for 404 errors at the very least.



为了为任何其他错误代码设置错误页面,您只需在 .htaccess文件中添加行即可。如果您想为上述五个错误提供错误页面,则 .htaccess文件可能看起来像这样:
ErrorDocument 400     /400.html 

ErrorDocument 401 /401.html

ErrorDocument 403 /403.html

ErrorDocument 404 /404.html

ErrorDocument 500 /500.html

.htaccess文件放在root/ 目录中应该会打勾。

对于引用: http://www.addedbytes.com/articles/for-beginners/error-documents-for-beginners/

或针对PHP错误; http://perishablepress.com/advanced-php-error-handling-via-htaccess/

关于file - .htaccess |您是否必须在每个目录中为每个错误安装htaccess,还是在根目录中仅安装一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19649591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com