Zend Framework application without virtual hosts

2019-02-05 07:26发布

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?

4条回答
走好不送
2楼-- · 2019-02-05 08:05

use this .htaccess

RewriteEngine On
RewriteRule ^(.*)$ public/$1?%{QUERY_STRING} [QSA,L]

and put this in application.ini

resources.frontController.baseUrl = "/myapp/"
查看更多
太酷不给撩
3楼-- · 2019-02-05 08:07

Put .htaccess file wit the following content to your myapp directory:

RewriteEngine on
RewriteRule (.*) public/$1
查看更多
我命由我不由天
4楼-- · 2019-02-05 08:10

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.

查看更多
聊天终结者
5楼-- · 2019-02-05 08:22

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.

查看更多
登录 后发表回答