title: how can remove '/public' from url using htaccess for localhost and host server?
body: <p>I'm using zend framework 2 on xampp. I created .htaccess file in the root('htdocs/zendtest/.htaccess') which has the following code,</p>
  
  <pre><code>Options +FollowSymLinks
  RewriteEngine On
  RewriteCond %{HTTP_HOST} $ [NC]
  RewriteCond %{HTTP_HOST} !/zendtest
  RewriteRule ^(.*)$ /zendtest/public/$1 [R=301,L]
  </code></pre>
  
  <p>my <strong>'zentest/public/.htaccess'</strong> code is,</p>
  
  <pre><code>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]
  </code></pre>
  
  <p><strong>'zentest/public/index.php'</strong> code:</p>
  
  <pre><code>&lt;?php
  /**
   * This makes our life easier when dealing with paths. Everything is relative
   * to the application root now.
   */
  chdir(dirname(__DIR__));
  
  // Setup autoloading
  require 'init_autoloader.php';
  
  // Run the application!
  Zend\Mvc\Application::init(require 'config/application.config.php')-&gt;run();
  </code></pre>
  
  <p>when I open 'localhost/zendtest' on browser then it takes me to 'localhost/zendtest/public'.I want to remove 'public' from the url by setting htaccess only(which will work both in localhost and online server),without using virtual host.how can I do that ?(theres no 'index.php' file in 'localhost/zendtest/' directory)</p>
  
  <p>-thanks.</p>
  
  <p><strong><em>Edit:</em></strong></p>
  
  <p><img src="https://i.stack.imgur.com/xJ4Ff.png" alt="enter image description here"></p>
  
  <p><strong><em>Update:</em></strong></p>
  
  <p><strong>directory:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/FPzHF.png" alt="enter image description here"></p>
  
  <p>I have the following .htaccess (according to Ravi Thapliyal's answer) in the 'zendtest/' folder (theres no 'zendtest/index.php' now in the 'zendtest' folder.just .htaccess. all other folder structures are same as the 'directory' picture.)</p>
  
  <pre><code>Options +FollowSymLinks -MultiViews
  RewriteEngine On
  RewriteBase /zendtest/
  
  RewriteCond %{REQUEST_URI} !/public [NC]
  RewriteRule ^(.*)$ public/$1 [L]
  </code></pre>
  
  <p>but it has now the following issue when open 'localhost/zendtest/' on the browser-</p>
  
  <p><img src="https://i.stack.imgur.com/nPO4W.png" alt="enter image description here"></p>
  
  <p><strong><em>RESOLVED:</em></strong></p>
  
  <p>I had to make some changes like the following picture (the .htaccess was good):</p>
  
  <p><img src="https://i.stack.imgur.com/jKx6t.png" alt="enter image description here"></p>
  
  <p>and achieved the goal-</p>
  
  <p><img src="https://i.stack.imgur.com/O2M5P.png" alt="enter image description here"></p>