A
A
Andrey2016-05-12 14:05:47
Nginx
Andrey, 2016-05-12 14:05:47

Redirect nginx gluing? remove .php?

location / {
rewrite ^/(\w+)$ /$1.php;
}

removes .php but let's say if you go to mysite.com/katalog.php then there is no redirect to mysite.com/katalog how to make gluing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2016-05-12
@VELIK505

location / {
if (!-e $request_filename){
rewrite ^(.*)$ /$1.php;
}
}
if ($request_uri ~ "\.php") {
rewrite ^/(.+)\.php$ /$1 permanent;
}
it all turned out like a roving

P
Puma Thailand, 2016-05-12
@opium

do not rewrite but redirect
gluing can be done by specifying the canonical url

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question