.htaccess文件意见(howto)

时间:2009-02-27 11:46:36

标签: .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

它出现了一个错误......我应该怎么做,重定向?

4 个答案:

答案 0 :(得分:0)

你只需要404.

答案 1 :(得分:0)

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

  

请注意,当您指定指向远程URL的ErrorDocument(即任何方法,例如前面带有http的方法)时,Apache会向客户端发送重定向,告诉它在哪里找到即使文档最终位于同一服务器上,该文档也是如此。这有几个含义,最重要的是客户端不会收到原始错误状态代码,而是会收到重定向状态代码。这反过来可能会混淆Web机器人和其他客户端,这些客户端尝试使用状态代码确定URL是否有效。    - ErrorDocument Directive

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


我要做的是在本地处理错误,并在页面上写下你想对寻找文档的人说些什么。也许是这样的:

  

此网站已移至example.com。但由于管理系统发生了愚蠢的变化,旧的URI无法映射到新的URI。对此我们深表歉意,希望您能找到您想要的页面。

结合搜索字段应该为用户提供一些答案并帮助他们面对的情况。

答案 2 :(得分:0)

如果您想知道哪些网页重定向是重要的,因为人们链接到这些网页,可能会有所帮助,Google web master tools。它将为您提供Google必须在您的网站上添加网页的外部链接的完整列表。如果你想做一些手动重定向,可能会很有用。

答案 3 :(得分:0)

您可以使用Google Webmaster Tools来了解人们可能会预订哪些网页。它是免费的,不需要您向网页添加任何脚本或任何内容(与Google Analytics不同)。

另外,我知道这对你没有帮助,但是cool URIs don't change。你刚从轨道上训练了你的PageRank。