Answer the question
In order to leave comments, you need to log in
How to fix incorrect URL processing?
When accessing a non-existent page with a certain type of URL, in particular if the beginning of the URL is the URL of an existing page, the server responds with 200 (OK) instead of 404 (Not found) and displays the existing page.
Example: http://bla-bla.ru/article/nazvanie/abrakadabra/
The site uses a bunch of nginx and php-fpm. I suspect that you need to edit the nginx config, but I'm far from an expert in this. The site got a little support and design tweaks. Tell me, please, in which direction to dig? Thanks in advance!
nginx config:
user www-data;
worker_processes 4;
timer_resolution 100ms;
worker_rlimit_nofile 4096;
worker_priority -5; #Увеличитвваем приоритет
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
server_tokens off;
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65000;
tcp_nodelay on;
client_max_body_size 50m;
gzip on;
#gzip_min_length 1100;
gzip_min_length 512;
gzip_disable "msie6"; #Быстрее, но работает только на новых версиях nginx
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 5;
#gzip_types text/plain application/x-javascript text/xml application/xml text/css;
gzip_vary on;
gzip_buffers 64 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/x-javascript application/xml application/xml+rss;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server {
listen 80;
server_name www.bla-bla.ru;
return 301 http://bla-bla.ru$request_uri;
}
server {
listen 80;
server_name 111.22.333.4;
return 301 http://bla-bla.ru$request_uri;
}
server {
listen 80;
server_name bla-bla.ru;
#return 301 $scheme://bla-bla.ru$request_uri;
server_name 111.22.333.4;
root /home/hosting/bla-bla.ru/www/;
index index.php index.htm index.html;
error_page 404 /404.php;
error_page 403 /404.php;
#error_page 403 404;
access_log /home/hosting/bla-bla.ru/log/nginx/access.log;
error_log /home/hosting/bla-bla.ru/log/nginx/error.log;
rewrite ^([^.]*[^/])$ $1/ permanent;
location /r {
rewrite ^/r/(.*) /r.php?rub=$1; #301 redirect
}
location /category {
rewrite ^/category/(.*) /category.php?rub=$1; #301 redirect
}
location /article {
rewrite ^/article/(.*) /article.php?rub=$1; #301 redirect
}
location /pages {
rewrite ^/pages/(.*) /pages.php?rub=$1; #301 redirect
}
location /author {
rewrite ^/author/(.*) /author.php?rub=$1; #301 redirect
}
location /user {
rewrite ^/user/(.*) /user.php?rub=$1; #301 redirect
}
location /register {
rewrite ^/register/(.*) /register.php?rub=$1; #301 redirect
}
location /main {
rewrite ^/main/(.*) /main.php?rub=$1; #301 redirect
}
location /profile {
rewrite ^/profile/(.*) /profile.php?rub=$1; #301 redirect
}
location /logout {
rewrite ^/logout/(.*) /logout.php; #301 redirect
}
location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|woff)$ {
access_log off;
expires max;
}
location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(.*)$;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param DOCUMENT_ROOT /home/hosting/bla-bla.ru/www;
fastcgi_param SCRIPT_FILENAME /home/hosting/bla-bla.ru/www$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED /home/hosting/bla-bla.ru/www$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60000;
fastcgi_send_timeout 180000;
fastcgi_read_timeout 180000;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /\.ht {
deny all;
}
location /phpmyadmin {
auth_basic "Enter Super Secret password!";
auth_basic_user_file /home/hosting/.htpasswd;
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_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_connect_timeout 60000;
fastcgi_send_timeout 180000;
fastcgi_read_timeout 180000;
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;
}
}
upstream php {
server unix:/var/run/php5-fpm.sock;
}
Answer the question
In order to leave comments, you need to log in
In location / write
try_files $uri $uri/ =404
or so
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location "/"
{
index index.php index.html index.htm; # index file
options try_files $uri $uri/ =404; # check if there is a file from the request on the disk, otherwise return a 404 error
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question