Posts Tagged zend framework
zend framework htaccess rewrite rule
Posted by Wil in zend framework htaccess on June 27, 2009
This tutorial is about how to create rewrite rule for zend framework installed on Apache server Ubuntu linux operating system.
Once you finished your apache/php/ mysql installation , you will need to configure apache virtual host for your new project.
open etc/apache2/sites-enabled directory, you will see file called 000-default, this is default apache configuration file you will need to create new file called just like your project directory. For example, in your var/www/ directory you have a folder named /zendtest , created file should be called zendtest, file should be without any extension.
Edit created file and insert these lines :
Our directory structure is just like mentioned on Zend Framework Quick start, please visit Zend Framework website for more information.
ServerAdmin webmaster@localhost
ServerName zendtest
DocumentRoot /var/www/zendtest/public
ErrorLog /var/log/apache2/mysite_error.log
CustomLog /var/log/apache2/mysite_access.log combined
# this entry is necessary to allow the virtual host to enable mod rewrite using htaccess
Options Indexes FollowSymLinks
AllowOverride All
allow from all
Our project located in the public directory, there is the place for our .htaccess file.
Go to your web root directory, in our case is /var/www/zendtest/public (we redirected virtual host to this directory, check out apache code below) Create file called .htaccess and put these lines inside :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Now let’s restart apache, the command to restart apache is sudo etc/init.d/apache2 restart (if you are not sure what is your apache version, open /etc directory and find apache directory, it may be 2 or 2_2)