Answer the question
In order to leave comments, you need to log in
How to remove slash from URI in nginx?
I have a project. There was a task to remove multiple slashes in the url address. For example:
domain.com/ru///courses I
need to redirect
http://domain.com/ru/courses
I
use docker and in the nginx container I tried different settings from Google, but I check it does not work on local
Answer the question
In order to leave comments, you need to log in
server {
if ($request_uri ~ "//") {
rewrite ^ $uri permanent;
}
merge_slashes on
try something like
merge_slashes off;
if ($request_uri ~* "\/\/") {
rewrite ^/(.*) $scheme://$host/$1 permanent;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question