[ nginx ] url rewrite

From `nginx.conf`, we have include `/etc/nginx/conf.d/*.conf` and `/etc/nginx/sites-enabled/*`, so we can include on any of this files.

/etc/nginx/nginx.conf

http{
...
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

Add the following code in the server section.

server{
...
# Verify URLs (wk)
# curl -I "http://localhost:7771/cache_buster/mock/whatever/?userId=1234&noAjax=1"
location /cache_buster {
  alias /var/www/html/whatever/path/it/is/;
  index index.html index.htm index.php;

  if (!-f $request_filename) {
            rewrite ^/cache_buster/(.+)$ /whatever/URL/path/cache_buster.php?path=$1 last;
            break;
        }
}
...
}

Then restart nginx.

sudo service nginx restart
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