March 9, 2013

Running a Zend Framework Project on a shared server

Question by Mikey

I’m trying to upload my ZF Project to shared hosting

On my XAMPP, ZF’s index page is located (and I access my page) at http://localhost/ZFprojectname/public

On the shared hosting in the root directory I have installed Joomla.

I want to access my ZF in the manner of http://mywebsite.com/booking/

so in this case, when going to http://mywebsite.com/booking/ I should be accessing ZF’s public folder (as far as I understand).

And, I’d like to put my ZFproject in public_html/somefolderName/

How would you do it?

Answer by Starx

Shared hosting do not support defining Document Root path so you can use .htaccess to forward the request to public folder instead.

Create a .htaccess file inside the booking directory with the following rule.

RewriteEngine On

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!