Laravel 5.2, Input::all() is empty - php

I have strange problem. On localhost everything is ok. But on my production website function Input::all() return empty Array.
For example http:://mypage.com?action=run etc.
nginx configuration
server {
root /usr/share/nginx/www/g2g/public;
index index.html index.htm index.php;
server_name mypage.com www.mypage.com;
location / {
try_files $uri $uri/ /index.html /index.php;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}

Thanks, for help.
Should be.
location / {
try_files $uri $uri/ /index.html /index.php?query_string;
}
in nginx configuration file

In nginx configuration, it should be this.
location / {
try_files $uri $uri/ /index.html /index.php?$query_string;
}
This is important - $query_string
Hope much helpful with saving time.

Related

Nginx with wordpress 404 on all pages

Although this issue has been answered many times but still its not working for me.
I am getting 404 on all pages except home page on Nginx.
I am posting in my configuration below:
server {
listen 80 ;
listen [::]:80;
root /var/www/html/p/swear;
index index.php index.html index.htm;
server_name skinnybikiniswimwear.org;
location / {
try_files $uri /$uri/ /index.php?args =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri /index.php?args =404;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
I am not able to find the issue in this configuration.
Wordpress is installed at: /var/www/html/p/swear
Thanks
Try this :
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$is_args$args =404;
}
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
Having had a lot of failures configuring wordpress to work with nginx, the rewrite rule solves every issue with the 404 errors.
try removing slash in front of /$uri/
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php;
}
Images does not because you dont have nothing in your server block about images. You have to add the images into your server block.
For example:
location ~* ^.+\.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mp3)$ {
root /home/example/public_html
}

Laravel 5.4 Nginx 1.10 PHP 7 route except "/" are returning 404

This is my config
server {
listen 80;
listen [::]:80;
server_name mysite.com;
root /var/www/site/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files \$uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}
The root of my site is accessible, all other routes are returning a 404 error.
Thanks in advance.
Cheers.
A few changes ... I run php 7.1 ...
location... try /index.php?$query_string; as in the example below...
server {
listen 80;
listen [::]:80;
server_name mysite.com;
root /var/www/site/public;
index index.php index.html;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Make sure your PHP-FPM runs same user as nginx
i.e. sudo vim /etc/php/7.1/fpm/pool.d/www.conf
...
user = nginx
group = nginx
...
listen.owner = nginx
listen.group = nginx
...
Then sudo systemctl restart php7.1-fpm.service
This is my configuration.
server {
listen 80;
root /home/user/projects/apple/public;
index index.php index.html index.htm;
server_name apple.dev;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I am not sure what the difference is, but I deleted the config file and made a copy of the default config, made changes to the lines I needed to. (i.e. server_name, root)
And it started working.

Nginx Wordpress Permalinks without index.php

I have nginx running with php 7 fpm.
My Wordpress permalinks are setup with /%postname%/. assuming my domain is example.com I want to have permalinks like that: example.com/postname/ But this leads to an error. I can find the post with this link: example.com/index.php?postname/
How do I get rid of the index.php? in the links?
Edit
My Nginx config
server {
server_name localhost;
root /var/www/;
index index.html index.htm index.php;
location ~\.php$ {
try_files $uri =404;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI $args;
}
location / {
try_files $uri $uri/ /index.php$args;
}
location /wordpress/ {
try_files $uri $uri/ /wordpress/index.php?$args;
}
}
You question implies that WordPress is installed at location /, so I am not sure why you have a location /wordpress also.
There are some issues with your configuration.
The value for REQUEST_URI should be set to $request_uri which is probably already the default value in the fastcgi_params file. This is the parameter that index.php uses to decode the pretty permalink.
Delete the line fastcgi_param REQUEST_URI $args;.
Your try_files statement is missing a ?. Use either:
try_files $uri $uri/ /index.php?$args;
Or:
try_files $uri $uri/ /index.php;
I have found that passing $args to /index.php is not necessary with WordPress.

Returns 404 if =404 is in try_files

Webpage always returns 404 if the =404 is in the try_files
Webserver is Nginx
I can access www.mydomain.com/admin/ just fine (contains a index.php)
if I go to www.mydomain.com/player/players/ it doesn't work (players is players.php) and there are no index files in player.
Removing =404 from the first try_files makes everything work as if there isn't anything wrong but then etc www.mydomain.com/filethatdoesentexist/ returns "no input file"
My code
location / {
try_files $uri $uri/ $uri.html #rewrite =404;
}
location #rewrite {
rewrite ^ $uri.php last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include fastcgi.conf;
}
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
location /admin/ {
try_files $uri $uri/ $uri.html #rewrite;
}

Phalcon and nginx - framework run only indexController

I am using Phalcon and Nginx, and i have a problem.
When I go to http://myapp.dev/segmentation Phalcon should run SegmentationController and its indexAction() method. But instead, Phalcon is running IndexController(default controller for "/"). I think problem is with Nginx configuration, because all works fine under Apache.
Here is my Nginx site configuration:
server {
listen 80;
server_name myapp.dev;
index index.php index.html index.htm;
set $root_path '/var/www/myapp/public';
root $root_path;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri $uri/ =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri $uri/ =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
}
USe this config
try_files $uri $uri/ #rewrite;
location #rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
Working Config
Its the problem with location directive
Use this configuration.
location / {
root $root_path;
index index.php index.html index.htm;
# if file exists return it right away
if (-f $request_filename) {
break;
}
# otherwise rewrite it
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?_url=/$1 last;
break;
}
Hope this helps!
Happy Coding !!!

Categories