2009-02-27 72 views
0

我喜歡製作一個.htaccess文件來重定向我從網站上得到的任何錯誤。.htaccess文件意見(howto)

我已經刪除了舊網站的所有頁面。但我不知道人們已經預訂了哪些網頁。

新的網頁和網站結構是完全不同的......所以沒有頁面與舊的頁面是一樣的,而不是事件索引文件從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 =工程

呢?想出一個錯誤...我該怎麼做,重定向?

+0

你的問題是什麼? – Gumbo 2009-02-27 12:38:12

+0

你會做什麼?你做什麼? – menardmam 2009-02-27 13:05:04

回答

0

你應該知道,絕對URL改變原有的錯誤狀態代碼重定向狀態代碼:

注意,當您指定ErrorDocument指向遠程URL (即任何有諸如http前面的方法的東西),Apache都會發送重定向到客戶端,告訴它在哪裏找到文檔,即使文檔最終位於同一臺服務器上。這有幾個含義,最重要的是客戶端不會收到原始錯誤狀態碼,而是會收到一個重定向狀態碼。這反過來可能會混淆網絡機器人和其他客戶端,這些客戶端試圖使用狀態代碼來確定URL是否有效。 - ErrorDocument Directive

因此,而不是發送404 Not Found的答案未找到資源,Apache將大概發送302 Temporary Redirect


我會做的是在本地處理錯誤,並在頁面上顯示任何要對正在查找文檔的人說的任何內容。可能是這樣的:

本網站已移至example.com。但由於管理系統發生了一些愚蠢的變化,舊的URI不能映射到新的URI。我們對此表示歉意,並希望您能找到您要查找的頁面。

與搜索字段相結合應該爲用戶提供一些答案和幫助他們面對的情況。

0

如果你想知道哪些頁面重定向,因爲人們鏈接到它們,可能有用的一件事是Google web master tools。它會爲您提供Google必須鏈接到您網站的外部鏈接的完整列表。如果你想做一些手動重定向可能會有用。

0

您可以使用Google Webmaster Tools瞭解人們可能已預訂的頁面。它是免費的,不需要你添加任何腳本或任何東西到你的網頁(不同於谷歌分析)。

另外,我知道這根本不是在幫你,而是cool URIs don't change。你剛剛從軌道上燒掉了你的PageRank。