Domanda

I have a problem with ZF on my new server during JS file inclusions. Including external JS (google api) is no problem. It seems, that zf want to load the JS files not relative.

The errormessage, displayed by FireBug in the Srcipt Tag of the html Console:

<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. 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
  2. Mod rewrite not enabled
  3. Missing or bad .htaccess file in public
  4. Missing "Allow Override = All" in the 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
  2. Mod rewrite is enabled, I can browse any page, controller, action
  3. .htaccess is default and present
  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

$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:

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. Now I set up two debian squeeze and on both systems I got these problems.

If I copy the project folder to a lenny system (same vhost config), it works fine.

May be someone has a idea how I can fix this...

Thx a lot

È stato utile?

Soluzione

Solved by renaming the javascript folder. See my comments above for more details

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top