Home / Zend Framework / How to remove “public” from url using routeing in zend framework 2

How to remove “public” from url using routeing in zend framework 2

Create index.php on ZF2 root directory and add the following content:

Select Code
<?php 
define('REMOVE_PUBLIC_FROM_URL', true);
include 'public/index.php';


Create .htaccess on ZF2 root directory and add the following content:

Select Code
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteRule .* index.php


Finally, add this conditional statement in the top of your layout.phtml file:

Select Code
<?php 
if (defined('REMOVE_PUBLIC_FROM_URL')) {
  $this->plugin('basePath')->setBasePath($this->basePath().'/public');
} ?>

About v.shakya

I am V.Shakya, Freelance PHP Programmer. I like to share my ideas, views and knowledge to all of you who come across my website. I am young, enthusiastic, highly motivated and self disciplined person. I completed my studies in Master of Computer Application and currently giving my technical expertise to one of the Big IT company. I have more than Ten years of experience in vast field of Programming , Designing and Development of websites and various software's.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Welcome to VShakya

For this week my all price is very low !

Don't miss to get my services

Thanks

 

Contact us