search

Home  >  Q&A  >  body text

nginx configures multi-directory access

Operating system: ubuntu13.10
Server: nginx 1.6

Configure nginx to access different directories according to different URL points
Use location/directory name { ... } to access different directories

But I want to build laravel4 framework, and I want to parse /coolwifi/test directly into /coolwifi/public/index.php/test, but an error will be reported:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
But access through http://localhost/coolwifi/public/index.php/test is possible
what should I do?

The default configuration file is as follows:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

<code>server {

    listen 80 default_server;

    listen [::]:80 default_server ipv6only=on;

 

    root /home/kimhwawoon/nginx;

    index index.php index.html index.htm;

 

    # Make site accessible from http://localhost/

    server_name localhost;

 

    location /coolwifi/ {

                index index.php;

                #if (!-e $request_filename) {

                #    rewrite ^/(.*)$ /public/index.php? last;

                #    break;

                #}

                try_files $uri $uri/ /coolwifi/public/index.php?$args;

        }

 

        location /phpmyadmin/ {

                index index.php

                try_files $uri $uri/ /phpmyadmin/index.php?$args;

        }

 

    location /swagger/ {

        index index.html index.php;

    }

 

    location /doc/ {

        alias /usr/share/doc/;

        autoindex on;

        allow 127.0.0.1;

        allow ::1;

        deny all;

    }

 

        location ~ \.php$ {

                  fastcgi_pass 127.0.0.1:9000;

                  fastcgi_index index.php;

                  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                  include fastcgi_params;

        }

}

</code>

天蓬老师天蓬老师2910 days ago995

reply all(2)I'll reply

  • 黄舟

    黄舟2017-05-16 17:29:14

    No matter how to set up a single server, the problem can be solved by setting up multiple servers, and configure multiple domain names in /etc/hosts of the local machine to point to the local, and use different domain names to distinguish different directories

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 17:29:14

    Have you ever used phalcon? I recently learned about phalcon, but according to your settings, all routes are redirected to index/index. Do you have a solution? Thank you

    reply
    0
  • Cancelreply