Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat should I use .htaccess for in Zend Framework 1.9.5 application?
    primarykey
    data
    text
    <p>I've written several Web MVC apps but never before in PHP, and I'm trying to figure out the best way to work with Zend Framework v1.9.5.</p> <p>I'm confused about the role of .htaccess in a Zend Framework 1.9.5 application. I have consulted many tutorials, books, and SO questions on Zend Framework (but most of them are for v1.8 at newest) and they all talk about the central role of the .htaccess file. I gather that .htaccess can be used to support virtual hosts, URL rewriting, and to allow Apache to serve static files without going through index.php but I'm not sure if this is current practice or still necessary in v1.9.5.</p> <p>Currently I have written a couple of pretty simple (HTML, CSS, jQuery) Zend Framework apps and created Apache virtual hosts for them in a test Ubuntu Server 9.10 environment. I didn't use any .htaccess files at all and the apps seem to work fine. </p> <p>Here's what I did so far:</p> <p>I created my apps using Eclipse/PDT and the zf.sh tool. I added css, images, and js directories to the public directory that 'zf create project' produced. These apps run fine on my local MAMP installation.</p> <p>On the server, I installed the Zend Framework in /usr/local/Zend/share/ZendFramework-1.9.5 and added /usr/local/Zend/share/ZendFramework-1.9.5/library to 'include_path' in php.ini.</p> <p>I copied the apps to the server directories /home/myadmin/public_html/domain[12]/com.</p> <p>I created virtual hosts by adding entries in the Apache available-sites directory as outlined in <a href="http://articles.slicehost.com/2008/12/17/ubuntu-intrepid-apache-virtual-hosts-1" rel="nofollow noreferrer">Slicehost Virtual Host Setup</a>. I assign DirectoryIndex = index.php and DocumentRoot = /home/myadmin/public_html/domain[12]/com/public. Both apps seem to work fine.</p> <p>Do I need to use .htaccess files? For what?</p> <pre><code>*** EDIT - My Solution </code></pre> <p>Based on Richard's link, I moved the rewrite statements that usually live in .htaccess into my virtual host definition, and now my applications don't use a .htaccess file. My domain1.com virtual host file looks like:</p> <pre><code>&lt;VirtualHost *:80&gt; # Define admin email, server name, and any aliases ServerAdmin webmaster@domain1.com ServerName domain1.com ServerAlias www.domain1.com # Only serve files from inside this directory DocumentRoot /home/myadmin/public_html/domain1.com/public # Directly serve any requested files that exist in DocumentRoot; # otherwise redirect the request to the index.php script RewriteEngine off &lt;Location /&gt; RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ /index.php [NC,L] &lt;/Location&gt; # Set up log file locations LogLevel warn ErrorLog /home/myadmin/public_html/domain1.com/data/logs/error.log CustomLog /home/myadmin/public_html/domain1.com/data/logs/access.log combined &lt;/VirtualHost&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload