We have a site built with WordPress with nginx
web server. I want to do multiple redirection in one line of code in our nginx
file.
The code below runs smoothly:
location /wp-links-opml.php {
return 301 https://$host/page-not-found;
}
What I want to happen is redirect multiple files in just one config:
location /wp-links-opml.php /wp-config-sample.php /wp-load.php {
return 301 https://$host/page-not-found;
}
All of the files above belong in root
directory but nginx
prompts with nginx exited with code 1
Do you know how can I properly redirect multiple files in 1 config?
Note : I tried this How can I have same rule for two locations in NGINX config? but in my case I am working with php files and not locations
Any help is greatly appreciated. Thanks.
That's how you could use one location for multiple files:
location ~ ^/(wp-links-opml.php|wp-config-sample.php|wp-load.php)$ {
return 301 https://$host/page-not-found;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.