search

Home  >  Q&A  >  body text

php - Phalcon can only access the / path, and other paths use indexAction. What's going on?

Following the steps below, a strange problem occurred.
I created a project, test, using the phalcon-devtools-2.0.13 tool.
Then, it runs successfully!
After that, I changed the following content:

< /p>

No problem:

< /p>

But:

< /p>

I added a route and something went wrong:

< /p>

Excuse me, what's going on? I am currently php5.6 phalcon2.0 nginx configuration:

 server {
           listen 80;
           server_name test;
           root /Users/ryugou/test/public;
           index index.php index.html index.htm;
           charset utf-8;
  
          location/{
                try_files $uri $uri/ /index.php;
         }
 
        location ~ \.php$ {
             try_files $uri =404;
 
             fastcgi_pass 127.0.0.1:9000;
             fastcgi_index /index.php;
 
             include fastcgi_params;
             fastcgi_split_path_info ^(.+\.php)(/.+)$;
             fastcgi_param PATH_INFO $fastcgi_path_info;
             fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          }
 
         location ~ /\.ht {
             deny all;
         }
 }
phpcn_u1582phpcn_u15822747 days ago730

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-05-16 13:15:09

    Post DI registration code

    reply
    0
  • PHPz

    PHPz2017-05-16 13:15:09

    The environmental problem is not a bug in the php version or Phalcon version, but an nginx configuration problem!
    Pitfall!
    Phalcon’s default URI information is obtained from $_GET['_url'], or it can be set to $_SERER['REQUEST_URI'].
    Using these two different methods to obtain requires different nginx configurations! ! (For details, please see Phalcon documentation Phalcon nginx configuration)
    This must be configured!
    Use $_GET['_url'] (default):

    location / {

        try_files $uri $uri/ /index.php?_url=$uri&$args;

    }
    Use $_SERVER['REQUEST_URI'], nginx configuration:

    location / {

        try_files $uri $uri/ /index.php;

    }
    If you want to use $_SERVER['REQUEST_URI'] normally, it doesn't matter if nginx is configured, you still have to modify it in the php code:

    use PhalconMvcRouter;
    $router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI);

    reply
    0
  • Cancelreply