Configure Apache for Zend Framework

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Configure Apache for Zend Framework

Post 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
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Configure Apache for Zend Framework

Post 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
Post Reply