Hi $router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI); seems to not working
I did try_files $uri $uri/ /index.php?$uri&$args;
i tried this too try_files $uri $uri/ /index.php;
|
Apr '13 |
5 |
2200 |
4 |
Hi $router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI); seems to not working
I did try_files $uri $uri/ /index.php?$uri&$args;
i tried this too try_files $uri $uri/ /index.php;
Igor, i am using nginx and wrote nginx rules. And i don't want to use $_GET['_url'], I wanted to use $_SERVER['REQUEST_URI'], i have got problem with this kind of setup :) Look at https://docs.phalcon.io/en/latest/reference/routing.html#uri-sources
Ok i've tested, it works on 1.0.0 Required rules on apache <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-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;
});
Hi, are you using the following instructions: https://docs.phalcon.io/en/latest/reference/nginx.html
Could you print your $_SERVER var?
Hi, I am using modified Basic configuration, and it works:
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::URI_SOURCE_SERVER_REQUEST_URI); and
.......
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['REQUEST_URI'] Is there any working example tiny working bootstrap index file which works?
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::LEVEL_MAIN_LAYOUT my website hangs, after some minutes i discovered that it sould be \Phalcon\Mvc\View::LEVEL_MAIN_LAYOUT
I have just did the same mistake at Router :) It shouldn't be $router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI); It should be $router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI); // this is working :)
Nginx server configuration should use try_files instead of conditional if. I advise to change configuration in documentation to this way:
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;
}
}
and with $router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI); to this
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;
}
}