Page 1 of 1

Configure Apache for Zend Framework

Posted: Thu Mar 26, 2009 7:45 am
by Stryks
Hi Guys,

Just wondering if anyone out there knows what the best way to configure my test environment to point to the the 'public' subfolder of zend framework projects when you open the base level folder.

Basically, I have a few projects side by side, and I'd like everything to behave with the same URLs that would be present when live.

So, to use a basic example, if I were setting up the ZF quickstart project, I'd want my url to be 'http://localhost/quickstart' while actually loading 'http://localhost/quickstart/public' without upsetting any of the .htaccess directives which would be used when live.

Any help or advice would be great guys. Cheers

Re: Configure Apache for Zend Framework

Posted: Mon Mar 30, 2009 10:18 pm
by Stryks
Just in case anyone else is looking for a solution ...

Using the quickstart application as a baseline, you need to replace the last line of .htaccess file with ...

Code: Select all

#SWAP COMMENTED LINE BELOW IN PRODUCTION ENVIRONMENT
#RewriteRule ^.*$ /index.php [NC,L]
RewriteRule ^.*$ /Quickstart/public/index.php [NC,L]
... and then in bootstrap.php, under the following line ...

Code: Select all

$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');
... add ...

Code: Select all

if(APPLICATION_ENVIRONMENT != 'production')
    $frontController->setBaseUrl('/Quickstart/public');
Apparently, there was an issue with ZF versions before 7 that required an additional step because of a small bug.

Anyhow, this can be uploaded directly without modification, and the only file that will need editing is the .htaccess file (just to switch the commented lines).

Cheers