This article can be useful to anyone who is trying to add a PHP application, like WordPress or MediaWiki to the Web application that uses the Zend_Controller class, which is a part of Zend Framework.
If you created the application that uses the Zend_Controller class, as described at the “Zend_Controller / Getting Started†manual page, you may think about how to combine your application with an existing one. For example, with the blog-like application. This is a little bit more complex then just installing it into one of the subfolders of your application, because the mod_rewrite rule, specified at the manual page, does not give another application a chance to handle a request, passing all requests to the file specified in the rule. So, you need to tune up mod_rewrite and here is an example of doing so. The example shows how I installed the WordPress blog system and modified the .htaccess file correctly to run the installed application.
At the first step, I downloaded the WordPress package from its download page and unpacked it into the “apps/wordpress†subfolder of my Zend Framework application. My application resides in the document root folder of the Apache server and the server supports .htaccess files. The .htaccess file of the application contains two lines that configure mod_rewrite to send all requests to the intex.php file. Here they are:
RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
The first line enables the URL rewriting engine and the second one defines the rule, which configures server to redirect all requests to index.php. What I need to do is to modify this rule so that server redirects all requests to index.php, except those that are sent to files in the “/apps/wordpress†folder. This can be done using the RewriteCond mod_rewrite directive as follows:
RewriteEngine on
RewriteCond %{REQUEST_URI} !/apps/wordpress.*
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.phpThe new line in the .htaccess enables the rewrite rule only when the request URL does not begin with “/apps/wordpress†string. After that all requests that begin with “http://myproject/apps/wordpress/†will be processed as they are, without URL rewriting.
For each new application you may need to specify RewriteCond in the .htaccess, or you can specify one for a folder with applications:
RewriteEngine on
RewriteCond %{REQUEST_URI} !/apps/wordpress.*
RewriteCond %{REQUEST_URI} !/apps/wiki.*
RewriteCond %{REQUEST_URI} !/tests/phpunit.*
RewriteCond %{REQUEST_URI} !/tests/selenium.*
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.phpor:
RewriteEngine on
RewriteCond %{REQUEST_URI} !/apps/.*
RewriteCond %{REQUEST_URI} !/tests/.*
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php