我希望在“指定的控制器无效”的情况下找不到404

时间:2014-09-01 13:19:09

标签: .htaccess zend-framework

在我的zend框架1项目中,我有一个.htaccess文件,它会将不是文件的所有文件重定向到index.php这是.htaccess

RewriteEngine On
RewriteBase /


RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

因此,每个irelevent请求都将以index.php结束,并且错误Invalid controller specified和页面似乎有些错误。我希望在有无效请求时找不到404页面。这是我的配置文件

[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
autoMailUser = info@listab.ir
autoMailPassword = 
autoMailHost = mail.listab.ir
emailes = ""
searchIndexPath = APPLICATION_PATH "/SearchIndex"

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 1

resources.layout.layoutPath = APPLICATION_PATH "/layouts/"
resources.layout.layout = master

autoloaderNamespaces[] = "listab_"
doctrine.dsn = "mysql://root:@localhost/mylistab"

host = localhost
username = root
password = 
dbname = mylistab

resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = 
resources.db.params.dbname = mylistab
resources.db.params.driver_options.1002 = "SET NAMES utf8;"

resources.router.routes.useraddpage.route =/p/:user/:page
resources.router.routes.useraddpage.defaults.module = default
resources.router.routes.useraddpage.defaults.controller = book
resources.router.routes.useraddpage.defaults.action = vitrin

resources.router.routes.useradd.route =/p/:user
resources.router.routes.useradd.defaults.module = default
resources.router.routes.useradd.defaults.controller = book
resources.router.routes.useradd.defaults.action = vitrin

resources.router.routes.bookview.route =/book/view/:id/:page
resources.router.routes.bookview.defaults.module = default
resources.router.routes.bookview.defaults.controller = book
resources.router.routes.bookview.defaults.action = view

resources.router.routes.bookviewc.route =/book/viewcomments/:id/:page
resources.router.routes.bookviewc.defaults.module = default
resources.router.routes.bookviewc.defaults.controller = book
resources.router.routes.bookviewc.defaults.action = viewcomments

resources.router.routes.bookc.route =/book/buyconfirm/:id
resources.router.routes.bookc.defaults.module = default
resources.router.routes.bookc.defaults.controller = book
resources.router.routes.bookc.defaults.action = buyconfirm

resources.router.routes.bookbuy.route =/book/buy/:code
resources.router.routes.bookbuy.defaults.module = default
resources.router.routes.bookbuy.defaults.controller = book
resources.router.routes.bookbuy.defaults.action = buy

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

我该怎么做?

1 个答案:

答案 0 :(得分:0)

在制作中,你可能想要:

resources.frontController.params.displayExceptions = 0

这将为您提供更加用户友好的404页面,而不是“指定的无效控制器”例外。