[英]Zend Framework - Include JS does not work on new System
JS文件包含期间,我的新服务器上的ZF出现问题。 包括外部JS(google 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的包含方法:-> 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配置),则可以正常工作。
可能有人知道我该如何解决...
多谢
通过重命名javascript文件夹解决。 请参阅我的评论以获取更多详细信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.