L
L
lemast2018-04-26 19:13:22
Nginx
lemast, 2018-04-26 19:13:22

NGINX redirect internal pages from .php to /?

Good evening comrades, I have been suffering for 3 days.
You need to redirect the internal pages of the site from site.ru/page.php/ to site.ru/page/ I
tried different options, I managed to redirect from .php to / but when I go I get a 404 error
in htaccess, such a redirect is done without problems.
nginx.conf:
server {
listen *****:80;
server_name site.ru www.site.ru;
error_log /var/log/httpd/domains/site.ru.error.log error;
location /index.html {
return 301 $scheme://$host;
}
location / {
proxy_pass http://*.*.*.*:8080;
location ~* ^.+\.(html|jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|ttf|otf|webp|woff|txt|csv|rtf|doc |docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3 |mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
root /home/admin/web/site.ru/public_html ;
access_log /var/log/httpd/domains/site.ru.log combined;
access_log /var/log/httpd/domains/site.ru.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias /home/admin/web/site.ru/document_errors/;
}
location @fallback {
proxy_pass http://*.*.*.*:8080;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
disable_symlinks if_not_owner from=/home/admin/web/site.ru/public_html;
include /home/admin/conf/web/nginx.site.ru.conf*;
}
I would appreciate any help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Mukovoz, 2018-04-26
@castomi

if ($request_uri ~* "^(.*/)index\.(html|php)$") { return 301 $1; }

To be honest, your question is not entirely clear, it looks more like a complaint. Here is my version removes index.php and index.html to the root of the current folder. Did you ask this? If not, please ask a more specific question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question