简体   繁体   English

Zend Framework-Include JS在新系统上不起作用

[英]Zend Framework - Include JS does not work on new System

I have a problem with ZF on my new server during JS file inclusions. JS文件包含期间,我的新服务器上的ZF出现问题。 Including external JS (google api) is no problem. 包括外部JS(google API)没问题。 It seems, that zf want to load the JS files not relative. 看来,zf想要加载的JS文件不是相对的。

The errormessage, displayed by FireBug in the Srcipt Tag of the html Console: 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>

The page does not load the scripts, because it tries to get the files by the full url. 该页面不会加载脚本,因为它会尝试通过完整的URL获取文件。 This cannot work, because of the rewrite rules. 由于重写规则,这无法正常工作。 After I tried hundreds of things, I got these error at the same place: 在尝试了数百种方法之后,我在同一地方遇到了这些错误:

<p>The requested URL /javascript/helper.js was not found on this server.</p>

But this is the right relative link. 但这是正确的相对链接。

My Structure: 我的结构:

/var/www/project/
           -->application
           -->...
           -->public
              -->javascript
                 helper.js
                 <other JS Files>
             index.php
             .htaccess

When I searched for this error, I found these possible reasons: 当我搜索此错误时,我发现了以下可能的原因:

  1. Wrong or missing baseURL 错误或缺少baseURL
  2. Mod rewrite not enabled 未启用Mod重写
  3. Missing or bad .htaccess file in public 在公共场所丢失或损坏的.htaccess文件
  4. Missing "Allow Override = All" in the vHost vHost中缺少“允许替代=全部”
  5. no leading "/" slash in the relative path of the file 文件的相对路径中没有前导“ /”斜杠

None of them fits to my problem. 他们都不适合我的问题。

  1. I have no deeper "baseURL", so my default path is "" by directing the vhost directly in my /project/public folder 我没有更深的“ baseURL”,因此我的默认路径是通过直接在我的/ project / public文件夹中定向虚拟主机来实现“”
  2. Mod rewrite is enabled, I can browse any page, controller, action 启用了Mod重写功能,我可以浏览任何页面,控制器,操作
  3. .htaccess is default and present .htaccess是默认值并且存在
  4. Allow Override is set to All, my rewrite rules work fine with the rest of the project 将“允许覆盖”设置为“全部”,我的重写规则可以在项目的其余部分正常工作
  5. I try it without "/" in the beginning. 我尝试开头时不带“ /”。 No effect 没有效果

My layout has this inclusion methods for JS: --> layout.phtml 我的布局具有以下用于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();

The confusing thing is, that the stylesheet inclusion works. 令人困惑的是,样式表包含起作用。 This is the same technic 这是相同的技术

I include them by 我包括他们

$this->headLink()->appendStylesheet('/css/layout.css');
echo $this->headLink();

My .htaccess: 我的.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]

I have several ZF projects running on debian lenny and they work without any problems. 我有几个在debian lenny上运行的ZF项目,它们可以正常工作。 Now I set up two debian squeeze and on both systems I got these problems. 现在,我设置了两个debian压缩,在两个系统上都遇到了这些问题。

If I copy the project folder to a lenny system (same vhost config), it works fine. 如果我将项目文件夹复制到lenny系统(相同的vhost配置),则可以正常工作。

May be someone has a idea how I can fix this... 可能有人知道我该如何解决...

Thx a lot 多谢

Solved by renaming the javascript folder. 通过重命名javascript文件夹解决。 See my comments above for more details 请参阅我的评论以获取更多详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM