views:

26

answers:

1

I am using Zend framework on wamp. I am using .htaccess file to redirect the request to public/ directory. The .htaccess file i am using contains

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]

and now when I access the site folder it get redirected towards the public/index.php but it get an error. Here is my script, indicating where the error occurs.

<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library/'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);

Till this part it's working, the remaining portion causes the error

$application->bootstrap()
            ->run();

and Error is page not found error. Anyidea what is causing this

A: 

Hi ,

you could still use the default htaccess that ZF make it

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

and add this like to your application.ini

resources.frontController.baseUrl = "/foo/public"

where foo is the parent folder of all application

or add this function below inside the bootstrap function

protected function _initBaseUrl(){

    $fc = Zend_Controller_Front::getInstance();
    $fc->setBaseUrl("/foo/public");
}

and just to make sure that worked successfully add this to any controller's action

 var_dump($this->getFrontController()->getBaseUrl());
       die;
tawfekov