[英]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.