URI_SOURCE_SERVER_REQUEST_URI seems not working

Hi $router->setUriSource(Router::URISOURCESERVERREQUESTURI); seems to not working

I did try_files $uri $uri/ /index.php?$uri&$args;

i tried this too try_files $uri $uri/ /index.php;



368

Do you have option (Options All) under directory at virtual host ? And if u use rewrite rules in htacces needs to be

<IfModule modrewrite.c> RewriteEngine On RewriteCond %{REQUESTFILENAME} !-d RewriteCond %{REQUESTFILENAME} !-f RewriteRule ^(.*)$ index.php?url=/$1 [QSA,L] </IfModule>

Igor, i am using nginx and wrote nginx rules. And i don't want to use $GET['url'], I wanted to use $SERVER['REQUESTURI'], i have got problem with this kind of setup :) Look at http://docs.phalconphp.com/en/latest/reference/routing.html#uri-sources



368

Ok i've tested, it works on 1.0.0 Required rules on apache <IfModule modrewrite.c> RewriteEngine On RewriteCond %{REQUESTFILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] </IfModule>

DI EXAMPLE

//Specify routes for modules
$di->set('router', function () use($routes) {

    $router = new \Phalcon\Mvc\Router();
    $router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);

    return $router;

});

For me it doesn't work. I recompiled Phalcon tried $router = new \Phalcon\Mvc\Router(false); and $router = new \Phalcon\Mvc\Router();



368

Can you paste your di ?



81.1k

Hi, are you using the following instructions: http://docs.phalconphp.com/en/latest/reference/nginx.html

Could you print your $_SERVER var?

Hi, I am using modified Basic configuration, and it works: ```nginx server { server_name localhost.dev;

root /var/www/phalcon/public;
index index.php index.html index.htm;

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

location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
}

} ``` but i wanted to use $router->setUriSource(Router::URISOURCESERVERREQUESTURI); and ```nginx ....... location / { try_files $uri $uri/ /index.php; } ......... ```

I don't like to setup nginx rewrite rules like that with $GET['url '], i think that framework should handle this job itself by $SERVER['REQUESTURI'] Is there any working example tiny working bootstrap index file which works?



81.1k

I tested with the following conf and it's working

https://gist.github.com/phalcon/5296737

Hi, thank you for quick response.

I did trivial mistake from my side ... sometimes tiny typo makes big waste of time :) When i tried to disable View::LEVELMAINLAYOUT my website hangs, after some minutes i discovered that it sould be \Phalcon\Mvc\View::LEVELMAINLAYOUT

I have just did the same mistake at Router :) It shouldn't be $router->setUriSource(Router::URISOURCESERVERREQUESTURI); It should be $router->setUriSource(\Phalcon\Mvc\Router::URISOURCESERVERREQUESTURI); // this is working :)

Nginx server configuration should use tryfiles instead of conditional if. I advise to change configuration in documentation to this way: ```nginx server { servername localhost.dev;

root /var/www/phalcon/public;
index index.php index.html index.htm;

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

location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
}

} ```

and with $router->setUriSource(\Phalcon\Mvc\Router::URISOURCESERVERREQUESTURI); to this ```nginx server { server_name localhost.dev;

root /var/www/phalcon/public;
index index.php index.html index.htm;

location / {
    try_files $uri $uri/ /index.php;
}

location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
}

} ```