Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend and .htaccess

My default 'zend' app has this default structure

/zend + webroot
    /application
    /config
    /library
    /public
        .htaccess
        index.php

and the default .htaccess redirects the various controller/action details via ./public/index.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

I use this default url to access the app

http://domain/index.php

I've now moved to a shared host, where the webroot is above the 'zend' root.

/webroot
    /zend
        /application
        /config
        /public
            index.php
           .htaccess

but i can only access my app via this URL

http://domain/zend/public/index.php

i want to be able to use

http://domain/zend/index.php

and have .htaccess redirect.

and i'm wondering how i can tweak the .htaccess file to redirect the URL requests. I read this tutorial but i didn;t work for me

/webroot
    /zend
        .htaccess
        /application
        /config
        /library
        /public
            index.php

This is the .htaccess content in this case

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]

Can anybody spot anything?

like image 633
emeraldjava Avatar asked Jan 04 '10 23:01

emeraldjava


2 Answers

Create zend/index.php containing this code:

<?php include 'public/index.php';

Now create zend/.htaccess containing this code:

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteRule .* index.php

Make sure that your images/css/js files are all within zend/public/ and do not remove the zend/public/.htaccess file :)

Don't forget that the request's baseUrl doesn't include '/public', so you'll need to add it yourself when you reference public facing files.

Regards,

Rob...

like image 69
Rob Allen Avatar answered Oct 27 '22 20:10

Rob Allen


Remember to change your RewriteBase.

like image 33
Bill Karwin Avatar answered Oct 27 '22 20:10

Bill Karwin