.htaccess - .htaccess文件意见(howto)

标签 .htaccess error-handling

我喜欢制作一个.htaccess文件来重定向从网站上收到的任何错误。

我已删除旧站点中的所有页面。但是我不知道人们在书中写了几页。

新的网页和网站的结构完全不同...因此,没有页面与旧的页面相同,更不用说索引文件从index.html更改为index.php。

所以这是我上传到服务器的.htaccess文件...

随时发表评论,并给我您的观点,您将做什么?

也许这是一个过大的杀伤力...但是有效!这是文件:

#404 - Not Found The requested URL was not found on this server
ErrorDocument 404 http://acecrodeo.com/new/01-acec.php?lang=fra

#400 - Bad Request Your browser sent a request that this server could not understand
ErrorDocument 400 http://acecrodeo.com/new/01-acec.php?lang=fra

#401 - Authorization Required This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
ErrorDocument 401 http://acecrodeo.com/new/01-acec.php?lang=fra

#403 - Forbidden You don't have permission to access on this server
ErrorDocument 403 http://acecrodeo.com/new/01-acec.php?lang=fra

#405 - Method Not Allowed The requested method GET is not allowed for the URL
ErrorDocument 405 http://acecrodeo.com/new/01-acec.php?lang=fra

#406 Not Acceptable
ErrorDocument 406 http://acecrodeo.com/new/01-acec.php?lang=fra

#409 Conflict
ErrorDocument 409 http://acecrodeo.com/new/01-acec.php?lang=fra

##413 - Request Entity Too Large The requested resource does not allow request data with GET requests, or the amount of data provided in the request exceeds the capacity limit
ErrorDocument 413 http://acecrodeo.com/new/01-acec.php?lang=fra

#414 - Request-URI Too Large The requested URL's length exceeds the capacity limit for this server
ErrorDocument 414 http://acecrodeo.com/new/01-acec.php?lang=fra

##500 - Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request
ErrorDocument 500 http://acecrodeo.com/new/01-acec.php?lang=fra

#501 - Method Not Implemented GET to URL not supported
ErrorDocument 501 http://acecrodeo.com/new/01-acec.php?lang=fra

# ------------ i am not sure the usefullness of these.. put it anyway !

#301 - Moved Permanently The document has moved URL here
ErrorDocument 301 http://acecrodeo.com/new/01-acec.php?lang=fra

#302 - Found The document has moved URL here
ErrorDocument 302 http://acecrodeo.com/new/01-acec.php?lang=fra

#303 - See Other The answer to your request is located URL here
ErrorDocument 302 http://acecrodeo.com/new/01-acec.php?lang=fra

#304 - Not Modified A cached copy will be used
ErrorDocument 304 http://acecrodeo.com/new/01-acec.php?lang=fra

#408 - Request Time-out Server timeout waiting for the HTTP request from the client
ErrorDocument 408 http://acecrodeo.com/new/01-acec.php?lang=fra

#410 - Gone The requested resource is no longer available on this server and there is no forwarding address. Please remove all references to this resource
ErrorDocument 410 http://acecrodeo.com/new/01-acec.php?lang=fra

#411 - Length Required A request of the requested method GET requires a valid Content-length
ErrorDocument 411 http://acecrodeo.com/new/01-acec.php?lang=fra

php请求怎么样

如果我请求aaa.php(旧文件),而新文件请求aaa.php?lang = eng

它提出了一个错误...我该怎么办,重定向?

最佳答案

您应该知道,绝对URL会将原始错误状态代码更改为重定向状态代码:

Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as http in front of it), Apache will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code. — ErrorDocument Directive



因此,Apache可能会发送404 Not Found,而不是发送302 Temporary Redirect作为未找到资源的答案。

我要做的是用一个页面处理本地错误,该页面向正在寻找文档的人说您想要说的话。也许是这样的:

This website has moved to example.com. But due to a stupid change in the managment system, the old URIs can not be mapped to the new one. We apologize for this and hope you can find the page you were looking for.



结合搜索字段可以为用户提供一些答案并帮助他们解决所面临的情况。

关于.htaccess - .htaccess文件意见(howto),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/594439/

相关文章:

apache - 使用 Htaccess 的单域多框架?

php - SEO 友好的 .htaccess RuleRewrites

.htaccess - htaccess 中的变量,RewriteRule 问题

error-handling - 安装 "module list"模块后Drupal白屏

node.js - 用户定义的错误未打印

bash - 在 bash 脚本中,将所有错误视为成功退出(除了最后一个错误)的最佳方法是什么?

php - 提供压缩的 JavaScript 文件

apache - 如何使用 .htaccess 创建重定向以正确的路径而不是页面访问

c - MPI_Finalize 和断言?

php - 如何在 firefox 的网页上显示 php 错误信息?