Is it possible to configure web server on Windows (Apache or IIS) without setting up virtual hosts so Zend Framework application could be accessed with link like http://example.com/myapp rather than http://example.com/myapp/public?
-
Have a look at similar questions at SO: http://stackoverflow.com/questions/4151246/install-zend-framework-without-apache-virtual-hosts or http://stackoverflow.com/questions/4274839/zend-app-on-host-without-mod-rewrite-and-no-virtual-hosts – Marcin Feb 14 '11 at 13:08
-
I did but there's no answer to my question. I don't want the link to include 'public' – yarson Feb 14 '11 at 14:05
4 Answers
use this .htaccess
RewriteEngine On
RewriteRule ^(.*)$ public/$1?%{QUERY_STRING} [QSA,L]
and put this in application.ini
resources.frontController.baseUrl = "/myapp/"

- 380
- 2
- 10
-
1Great! This is what I needed. It works perfectly on Apache and should be easy enough to translate .htaccess rules to IIS web.config Thanks! – yarson Feb 18 '11 at 10:03
-
@Zebooka why did you use `?${QUERY_STRING}` and `[QSA]`? I thought `[QSA]` appends the query string already :) – Samuel Herzog Dec 09 '11 at 02:31
-
-
1
-
Where is the location of application.ini ? Shall I create a new file ? Where to put it ? – Mendes Jun 11 '16 at 20:46
-
Put .htaccess
file wit the following content to your myapp
directory:
RewriteEngine on
RewriteRule (.*) public/$1

- 711
- 11
- 24
-
It doesn't work. I get 404 error because 'myapp' is recognized as controller while it should default to 'index' – yarson Feb 14 '11 at 14:20
-
1I've a site where it works fine. I put this `.htaccess` to root directory (`../public`) and it has also another `.htaccess` in public directory that shipped with ZF. – ksimon Feb 14 '11 at 14:28
-
if it does not work, you can check out this site: http://blog.tasuki.org/htaccess-document-root-and-zend-framework/ – ksimon Feb 15 '11 at 07:04
-
Thanks for the link but it doesn't help in this case. These rules probably work ok if your application is hosted on domain level (http://example.com/) but the problems begin when it's in a folder (http://example.com/myapp) – yarson Feb 15 '11 at 10:00
Create a .htaccess file and place it into root direectory with following content
RewriteEngine on
RewriteRule (.*) public/$1
And add below line to your application/configs/applicaton.ini file
resources.frontController.baseUrl = "/myapp/"
There will be no error I will work fine.

- 2,337
- 2
- 31
- 43
As suggested in zend documentation here https://framework.zend.com/manual/2.4/en/user-guide/skeleton-application.html#using-the-built-in-php-cli-server, You can use the built-in CLI server using command
php -S 0.0.0.0:8080 -t public/ public/index.php
to run this just open command prompt and type above command like this
php -S 0.0.0.0:8080 -t {path_of_project's_public_folder} {path_of_project's_public_folder_upto_idex.php_file}
then hit enter and now you can open to your project like this http://localhost:8080/. Your application is running on 8080 port you can change it to something else like 8000 or 5050.
I hope it will help someone.

- 2,678
- 1
- 18
- 25