在JS文件包含期间,我的新服务器上存在ZF问题。 包括外部JS(谷歌api)是没有问题的。 看来,zf想要加载JS文件而不是相对的。
错误消息,由FireBug在html控制台的Srcipt标签中显示:
<script src="/javascript/helper.js" type="text/javascript">
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL http://project/javascript/helper.js was not found on this server. </p>
<hr>
<address>Apache/2.2.16 (Debian) Server at domain.squeeze Port 80</address>
</body></html>
</script>
页面不加载脚本,因为它试图通过完整的URL获取文件。由于重写规则,这不起作用。 在我尝试了数百件事之后,我在同一个地方遇到了这些错误:
<p>The requested URL /javascript/helper.js was not found on this server.</p>
但这是正确的相对链接。
我的结构:
/var/www/project/
-->application
-->...
-->public
-->javascript
helper.js
<other JS Files>
index.php
.htaccess
当我搜索此错误时,我发现了以下可能的原因:
它们都不适合我的问题。
我的布局有JS的这种包含方法: - &GT; layout.phtml
$this->headScript()->appendFile('/javascript/jquery_1.6.2/jquery.js','text/javascript');
$this->headScript()->appendFile('/javascript/jqueryui_1.8.16/jquery-ui.min.js','text/javascript');
$this->headScript()->appendFile('/javascript/jquery.metadata.js','text/javascript');
$this->headScript()->appendFile('/javascript/jquery.validate.js','text/javascript');
$this->headScript()->appendFile('/javascript/jquery.fileupload.js','text/javascript');
$this->headScript()->appendFile('/javascript/jquery.fileupload-ui.js','text/javascript');
$this->headScript()->appendFile('/javascript/methods_de.js','text/javascript');
$this->headScript()->appendFile('/javascript/helper.js','text/javascript');*/
echo $this->headScript();
令人困惑的是,样式表包含起作用。这是相同的技术
我把它们包括在内
$this->headLink()->appendStylesheet('/css/layout.css');
echo $this->headLink();
我的.htaccess:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
我有几个在debian lenny上运行的ZF项目,它们没有任何问题。 现在我设置了两个debian挤压,在两个系统上我都遇到了这些问题。
如果我将项目文件夹复制到lenny系统(相同的vhost配置),它可以正常工作。
可能有人知道如何解决这个问题......
很多
答案 0 :(得分:0)
通过重命名javascript文件夹解决。 有关详细信息,请参阅上面的评论