Skip to content

Instantly share code, notes, and snippets.

@rszuban
Last active September 18, 2018 08:25
Show Gist options
  • Save rszuban/ebfe7faad79dbc0f474e609b28451fcb to your computer and use it in GitHub Desktop.
Save rszuban/ebfe7faad79dbc0f474e609b28451fcb to your computer and use it in GitHub Desktop.
Redirecting requests to Wordpress xmlrpc.php to other URLs via Nginx Server block
server {
listen 80;
server_name your_amazing_site.com www.your_amazing_site.com;
root /var/www/your_amazing_site.com;
index index.php;
access_log /var/log/nginx/your_amazing_site.com.access.log;
error_log /var/log/nginx/your_amazing_site.com.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
# Redirect requests to xmlrpc.php file to Rick Astley - Never Gonna Give You Up video
location = /xmlrpc.php {
return 302 https://www.youtube.com/watch?v=dQw4w9WgXcQ;
access_log off;
}
# pass the PHP scripts to FastCGI server listening on unix sock
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php56-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment