Answer the question
In order to leave comments, you need to log in
How to accept GET requests?
There is a site (nginx + php). I'm trying to get a GET request to a controller. At first, there was a problem that when a link was made like site.ru/controller/action?login=test&pass=test, the Controller called the "action?login=test&pass=test" method, which naturally does not exist. wrote a rule for the router, which discards everything after the question. Great, now everything works, only in the action method itself, for some reason, I cannot accept GET.
The question is simple: how to get GET in this case? Or how is it done when using MVC?
UPD: Attached nginx config.
server {
listen 80;
root /var/www/site/public_html;
access_log /var/log/nginx/site.access.log;
error_log /var/log/nginx/site.error.log;
server_name site.ru *.site.ru;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php;
}
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;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
}
Answer the question
In order to leave comments, you need to log in
Thanks Aleksey POS_troi It was in nginx, it was worth doing this:
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}
Should we beg you to show the nginx config or will you show it yourself? :)
The minimal configuration looks like this:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
And don't forget to put cgi.fix_pathinfo = 0; in php.ini
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question