Thursday, August 14, 2014

Nginx - Simple dynamic sitemap rewrite configuration

A little note to remember...
The main goal is to create dynamic loading sitemap.xml file from some directory.
At the begining we have locale code. And sitemap file can requested from some directory.
Files should be placed to a particular directory.


location ~ /sitemap.xml|/([a-z][a-z]|[a-z][a-z]-[a-z][a-z])/(.*)sitemap.xml {
    root   /usr/local/www/apache22/data/project/;
    index /sitemap/sitemap.xml;
    try_files /sitemap/$1/$2/sitemap.xml /sitemap/$1/sitemap.xml;
}

Monday, June 23, 2014

Shell - Set GIT command output to variable

Just small note... I tried to make some shell script which works with GIT commands. So, I need to set shell output to some variable.
var=$(git pull)

I cannot do that with such approach. It always show me result.
The answer I found by link.
So we need to add a little change:
var=$(git pull 2>&1)

# or
var=$(git pull > /dev/null 2>&1)
Works!