I am focusing on a Zend Framework project where I have happened across a little of the problem. The issue arises from the truth that modules are second class people in Zend Framework. During my project, I would like for every module to possess a folder that contains files which should be utilized in the outdoors - files for example stylesheets, javascripts and pictures.

Now, how's this to become done. Having a Zend Framework project I've got a folder structure which appears like this:

  • application/
    • modules/
      • moduleOne/
        • public/
          • stylesheet.css
      • moduleTwo/
      • moduleThree/
  • public/
    • index.php

The conventional .htaccess file situated within the public/ folder holds this:

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]

The actual way it works, would be that the project's apache DocumentRoot may be the public/ folder. All demands will get rerouted with the index.php file where Zend Framework's router component gets control. Now, I am in no way a specialist with Apache nor mod_rewrite so pardon me if this sounds like just silly. I suppose I implement an additional part of the present rewrite rule to ensure that basically request http://project/public/moduleOne/stylesheet.css it'll for example resolve to /var/www/project/application/modules/moduleOne/public/stylesheet.css.

Therefore the steps which have to be done is to see if the very first aspect in the URI is public/ if it's, we go ahead and take next segment because the modules title and employ that within the path we are attempting to resolve to and try to serve the file.

Is whatsoever possible or does anybody possess a better suggestion?

Appreciate your time and effort Christian Rasmussen

With only mod_rewrite you cannot request files outdoors the document root. Therefore the only solution is by using symlink situated in document root directory and pointing towards the modules directory.