Answer the question
In order to leave comments, you need to log in
How to set up nginx 301 redirect from index.php to root /?
How to set up a 301 redirect from index.php to the root / on nginx, otherwise duplicates of the main page appear in the search results in the form of links to index.php, including with all sorts of parameters. There are no such links on my site. Apparently the search robot finds them on other sites. There are many different options on the Internet, but I would like to understand which method is best. Now I wrote this and it works:
index index.php;
location / {
try_files $uri $uri/ =404;
}
if ($request_uri ~ /index.php) {
return 301 /;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question