A little bit of nginx

Took me a moment to find out how to redirect a URL if the URL contains a certain word, in Nginx, here it is:

location ~ \.xml$ {
rewrite ^(.*)$ http://urltoberedirected.com/$1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://urltoberedirected.com/$1;
}

This one is going to redirect each URL which ends with .xml to urltoberedirected.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s