2013-01-16 60 views
1

我使用Zend Framework开发的模块,并且我一直在使用ZF创建项目 命令删除的index.php

当我尝试使用ip/folder/controller/action它给错误访问URL没有找到创建项目错误,当我尝试使用ip/folder/index.php/controller/action我能够访问,但我无法包括的js,在这两种情况下的CSS文件和我的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是

<?php 

    // Define path to application directory 
    defined('APPLICATION_PATH') 
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application')); 

    // Define application environment 
    defined('APPLICATION_ENV') 
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') 
     ? getenv('APPLICATION_ENV') : 'production')); 

    // Ensure library/ is on include_path 
    set_include_path(implode(PATH_SEPARATOR, 
    array(realpath(APPLICATION_PATH . '/library'), get_include_path(), 
))); 

/** Zend_Application */ 
require_once 'Zend/Application.php';  

// Create application, bootstrap, and run 
$application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini' 
); 
$application->bootstrap()->run(); 
0访问
+0

您需要启用模式改写建议的另一种方法。 – tasmaniski

+0

mod_rewrite已启用 –

+1

然后您的Web服务器不会看到.htaccess文件。你有Linux/Apache吗? – tasmaniski

回答

1

尝试增加这你的.htaccess:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^/]+/)*index.php 
RewriteRule ^index.php(.*)$ /path/to/your/installation$1 [R=301,L] 

替换/路径/到/你/安装使用正确的路径

+0

你能告诉我如何配置安装路径,例如 –

+0

你也可以这样做: RewriteCond%{THE_REQUEST}^[AZ] {3,9} \ /(.*)index\.php(.* )\ HTTP/[NC] RewriteRule^index \ .php(。*)$/$ 1 [R = 301,L] – thecodeassassin

+0

无论如何它应该指向index.php所在的位置。但后者的例子也应该涵盖你的用例。 – thecodeassassin

0

我只是添加这个到index.php文件的顶部:

$_SERVER["REQUEST_URI"] = str_replace('index.php', '', $_SERVER["REQUEST_URI"]); 

这是Rob Allen at Akrabat.com