views:

33

answers:

1

Hi,

I am building a web application with Zend Framework, and I need to point my app to the "public" folder of the application:

So basically when I call http://localhost/myapp it should display http://localhost/myapp/public/

I created a virtual host file called myapp into /etc/apache2/sites-available/:

    <VirtualHost *:80>
DocumentRoot /var/www/myapp/public/
 <Directory />
  Options FollowSymLinks
  AllowOverride None
 </Directory>
 <Directory /var/www/myapp/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
 </Directory>

</VirtualHost>

But it doesnt work. When I call http://localhost/myapp, it displays the directory structure of the app, and when I click on the "public" folder, then it displays what I want to be displayed by default... I never configured vhosts before and that's as far as I got with the tutorials about it....

all help appreciated!

A: 

Ok I found a way somehow... I don't think it's necessary the right/best way but...

in httpd.conf (in apache2 folder):

Listen 10089

<VirtualHost *:10089>

    DocumentRoot "/var/www/myapp/public"

    <Directory "/var/www/myapp/public">

        Order allow,deny

        Allow from all

    AllowOverride all

</Directory>

</VirtualHost>

My app is now accessible via localhost:10089 After enabling the rewrite mod in apache, I added the necessary .htaccess, one at the root of my app, redirecting everything to index.php (Zend framework support friendly url navigation and works that way):

RewriteEngine on

RewriteRule .* index.php

and a second .htaccess file inside my public folder to allow people to access .jpg,.ico,etc files and not being redirected to index for everything:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

Hope this will help some!

Piero