【问题标题】:Zend framework URL indexZend 框架 URL 索引
【发布时间】:2011-05-02 21:06:22
【问题描述】:

我安装了 Zend 框架 1.11.5 我有 Wamp 2.2 并正在运行 windows7。

我在 apache documentRoot('c:/wamp/www');'mysite' 文件夹结构中有一个文件夹(mysite):

/application
   /controllers
        IndexController.php
   /views
      /scripts
        index.phtml
   bootstrap.php
/library
/public
   /css
   /images
   /javascript
   .htaccess
   index.php

问题:如果我将浏览器指向“http://localhost/mysite/public/”,我可以正确看到我的索引页。但如果我指向“http://localhost/” mysite/public/index/' 或 'http://localhost/ejoin2ED/public/index/index' 我看到了 Wampserver 配置页面(我认为这是我拥有的另一个页面的输出,'index.php' inside 'c :/wamp/www')。

我应该看到 index.phtml 的内容吗??

谢谢

卢卡

.htaccess

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

index.php

//identify the location of th application dir in respect to 
//the botstrap file's location, and configure PHP's include_path to
//include the library directory's location

define('APPLICATION_PATH',realpath(dirname(__FILE__).'/../application/'));
set_include_path(APPLICATION_PATH.'/../library'.PATH_SEPARATOR.
get_include_path());

//give the zend framework the ability to load classes on demand,
//as you request them,rather than having to deal with require() statements.

require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();

//retrieve the BOOTSTRAP file
try
{
require'../application/bootstrap.php';  
}
catch(Exception $exception)
{
printf('Could not locate bootstrap.php');
exit(1);    
}

//start using the front controller in order to route all requests
Zend_Controller_Front::getInstance()->dispatch();

bootstrap.php

//configure the site environment status

defined('APPLICATION_ENVIRONMENT')
or define('APPLICATION_ENVIRONMENT','development');

//invoke the front controller
$frontController=Zend_Controller_Front::getInstance();

//identify the location of the controller directory
$frontController->setControllerDirectory(APPLICATION_PATH.'/controllers');

//create the env parameter so you can later access the environment
//status within the application

$frontController->setParam('env',APPLICATION_ENVIRONMENT);

//clean up all allocated script resources
unset($frontController);

【问题讨论】:

    标签: php zend-framework wamp document-root


    【解决方案1】:

    您的 htaccess 文件有问题。

    index.php 的斜线是问题

    RewriteRule ^.*$ /index.php [NC,L] 
    

    应该是

    RewriteRule ^.*$ index.php [NC,L]
    

    【讨论】:

    • 它将所有内容重定向到 index.php,但在您的情况下,它将所有内容重定向到根目录中的 index.php,'c:/wamp/www'
    猜你喜欢
    • 1970-01-01
    • 2012-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多