Redirect / to another path in Nginx
I needed to tweak my Nginx config to redirect / (slash) only on a Wordpress site to a completely different location but leave all other routing intact. There we have it.
server {
listen 80;
server_name here.robl.me;
root /var/www/wordpress;
index index.html index.htm index.php;
location = / {
rewrite ^ http://there.robl.me permanent;
}
location / {
try_files $uri $uri/ /index.php?$args;
# auth_basic "Restricted";
# auth_basic_user_file /etc/nginx/.htpasswd;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}