An one issue in my zend, i write rule in .htaccess to remove \"public\" from url as following,
--------------------------------------------------------------
zf2 and zf3 remove Public from URL
create index.php and .htaccess add file in root of project
add the line in index.php include_once("public/index.php");
and in .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
after that go to following path
Module->application(module name)->view->layout->layout.phtml change css and js path add public in path
before
->prependStylesheet($this->basePath('css/bootstrap.min.css'))
->prependFile($this->basePath('js/bootstrap.min.js'))
after
->prependStylesheet($this->basePath('public/css/bootstrap.min.css'))
->prependFile($this->basePath('public/js/bootstrap.min.js'))
also in image path
The following works for me using ZF2.2
Create index.php on ZF2 root directory and add the following content:
<?php
define('RUNNING_FROM_ROOT', true);
include 'public/index.php';
Create .htaccess on ZF2 root directory and add the following content:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteRule .* index.php
Finally, add this conditional statement in the top of your layout.phtml file:
<?php
if (defined('RUNNING_FROM_ROOT')) {
$this->plugin('basePath')->setBasePath($this->basePath().'/public');
} ?>
Enjoy!
Reference: http://akrabat.com/zend-framework/zend-framework-on-a-shared-host/
Yes, and you don't need Zend_Route
. Delete the public
folder and put the Zend Framework files from it (index.php
, .htaccess
, etc) in your root directory (e.g. htdocs
). You can place the application
folder and other Zend Framework files outside of your web root where they cannot be accessed over HTTP.
All you need to do is edit index.php
and change the APPLICATION_PATH
to the correct path. This way your Zend Application will run from your root directory and you won't need to use mod_rewrite
to hide the public folder.
See the last part of this answer for a similar example.