我開發了一個使用Zend框架的網站。爲了處理錯誤,我想在htaccess文件中添加以下幾行代碼,以便每當出現錯誤時都可以將用戶重定向到相應的行。Zend框架與htaccess
ErrorDocument 500 /errors/500.html
ErrorDocument 404 /errors/404.html
ErrorDocument 403 /errors/403.html
所以我的htaccess在/public
文件夾現在文件看起來是這樣的:
RewriteEngine on
# Rewrite rules for Zend Framework
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
# Security: Don't allow browsing of directories
Options -Indexes
# PHP settings
php_flag magic_quotes_gpc off
php_flag register_globals off
php_flag short_open_tag on
ErrorDocument 500 /errors/500.html
ErrorDocument 404 /errors/404.html
ErrorDocument 403 /errors/403.html
但是它似乎不工作,它不重定向我這些網頁,而是它會顯示這個經典的錯誤頁面。
Server錯誤
網站在檢索 http://www.mysite.com/wesgtsgsfd/sgsdf遇到一個錯誤。它可能因維護 或配置不正確而停機。
以下是一些建議:稍後重新加載該網頁 頁面。 HTTP錯誤500(內部服務器錯誤):在服務器試圖完成請求時遇到意外的 條件。
有沒有人有一個想法來修復我的htaccess文件,以便Apache可以正確處理錯誤並根據錯誤類型將它們重定向到錯誤頁面。
歡迎來到SO。 ;-)提交問題和格式的簡短評論。請注意,當您鍵入(!)您的問題時,您可以預覽一下您的問題在提交後會如何顯示。查看[Markdown格式幫助](http://stackoverflow.com/editing-help)可能會對您有所幫助。再次歡迎! –
通常,所有請求都使用一組標準的.htaccess規則路由到ZF應用程序。然後錯誤 - 包括404,500等 - 由ErrorController處理。你是說你明確想要在Apache(而不是ZF)級別處理它們嗎? –
我知道ErrorController是一個處理錯誤的選項。然而我真的不知道如何使用錯誤控制器(如何截取錯誤,並將它們重定向到zend中的錯誤控制器) 所以我認爲可能是htaccess將是一個更容易的選項 –