我读了很多关于如何将Zend Framework 1.12项目部署到生产环境的指南,我想我完成了所有步骤,但我无法在.htaccess上配置重写规则。首先要知道的是,服务器是共享的,所以,我无法访问任何配置,所以,问题只是重定向到我的/public/inedx.php文件。
首先,在我的主文件夹(/)中,我添加了一个.htaccess文件,其中包含基于官方指南(http://framework.zend.com/manual/1.12/en/project-structure.rewrite.html -> Rewriting inside a VirtualHost )
:的内容
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
我上传了这个文件到我的主(/)和404错误仍然显示。
然后,我在我的主(/)中添加了一个index.php,它是:
<?php
define('RUNNING_FROM_ROOT', true);
include 'public/index.php';
现在我的web正在工作,但还没有完全工作,我的意思是,没有css样式,没有js,也没有图像,但前提是我使用$this->baseUrl(),所以,在我的布局中,我使用这样的css链接:
> <link href="<?php echo $this->baseUrl()."/css/global.css"; ?>"
> rel="stylesheet" type="text/css">
出现404:
"NetworkError: 404 Not Found - http://www.mysite.com/css/global.css"
应该在什么时候http://www.mysite.com/public/css/global.css,所以,我编辑了我的布局,js和css现在可以工作了,但当我点击一个链接时,比如:
http://www.mysite.com/controller/action/#0-0
我又得到404…
那么,有人对此有经验吗?对付魔鬼?
提前谢谢。
不要
include 'public/index.php';
处理此问题的最佳方法是将public/index.php和.htaccess一起移动到根文件夹中。完成后,从修改index.php中的APPLICATION_PATH
/../application
至
application
我不确定是什么
define('RUNNING_FROM_ROOT', true);
应该做任何一件事。
您可以尝试以下url
RewriteEngine On
RewriteRule .* index.php
Zend和.htaccess