March 1, 2012

Zendframework project shows xyz.com/public/ so how to remove public

Question by Zuber Surya

My zendFramework application on server shows

xyz.com/public/login

i want it like

xyz.com/login

how to achieve this ? is it possible to do with .htaccess file.

Thanks in advance

Answer by Starx

This is my answer from another question, but seems to fit in this question too. In the case you already have a .htaccess file inside public, use the htaccess solution from below.

The problem seems to be due to the root not being routed to /public.

  1. The proper way: You need to setup a vhost and point the root to the public directory.

  2. Another Way: You need to redirect every request inside public directory. The .htaccess for this file would be

    RewriteRule ^.htaccess$ - [F]
    
    RewriteCond %{REQUEST_URI} =""
    RewriteRule ^.*$ /public/index.php [NC,L]
    
    RewriteCond %{REQUEST_URI} !^/public/.*$
    RewriteRule ^(.*)$ /public/$1
    
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^.*$ - [NC,L]
    
    RewriteRule ^public/.*$ /public/index.php [NC,L]
    

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!