# Redirect non-www to www

# Specific redirections
rewrite ^/blog/category/all/https\:$ /blog/category/all/https-? permanent;
rewrite ^/blog/category/all/https\:/ajax\.googleapis\.com$ /blog/category/all/_ajax.googleapis? permanent;
if ($args ~* ^C=D;O=A$){ rewrite ^/blog/category/all/https\:$ /blog/category/all/__C-D-O-A? permanent; }
if ($args ~* ^C=M;O=A$){ rewrite ^/blog/category/all/https\:$ /blog/category/all/__C-M-O-A? permanent; }
if ($args ~* ^C=N;O=D$){ rewrite ^/blog/category/all/https\:$ /blog/category/all/__C-N-O-D? permanent; }
if ($args ~* ^C=S;O=A$){ rewrite ^/blog/category/all/https\:$ /blog/category/all/__C-S-O-A? permanent; }
if ($args ~* ^C=D;O=A$){ rewrite ^/blog/category/all$ /blog/category/all/C-D-O-A? permanent; }
if ($args ~* ^C=M;O=A$){ rewrite ^/blog/category/all$ /blog/category/all/C-M-O-A? permanent; }
if ($args ~* ^C=N;O=D$){ rewrite ^/blog/category/all$ /blog/category/all/C-N-O-D? permanent; }
if ($args ~* ^C=S;O=A$){ rewrite ^/blog/category/all$ /blog/category/all/C-S-O-A? permanent; }
if ($args ~* ^C=D;O=A$){ rewrite ^/blog/category$ /blog/category/C-D-O-A? permanent; }
if ($args ~* ^C=M;O=A$){ rewrite ^/blog/category$ /blog/category/C-M-O-A? permanent; }
if ($args ~* ^C=N;O=D$){ rewrite ^/blog/category$ /blog/category/C-N-O-D? permanent; }
if ($args ~* ^C=S;O=A$){ rewrite ^/blog/category$ /blog/category/C-S-O-A? permanent; }

# Create pretty URLs
rewrite ^/([^/]+)$ /$1.html last;
rewrite ^/([^/]+)/([^/]+)$ /$1/$2.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6/$7.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6/$7/$8.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6/$7/$8/$9.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6/$7/$8/$9/$10.html last;
# End: Create pretty URLs

# Redirect all extensions to html
if ($is_args = ''){
	rewrite ^([^.]*)\.shtml$ $1.html permanent;
	rewrite ^([^.]*)\.phtml$ $1.html permanent;
	rewrite ^([^.]*)\.jhtml$ $1.html permanent;
	rewrite ^([^.]*)\.htm$ $1.html permanent;
	rewrite ^([^.]*)\.php$ $1.html permanent;
	rewrite ^([^.]*)\.aspx$ $1.html permanent;
	rewrite ^([^.]*)\.asp$ $1.html permanent;
	rewrite ^([^.]*)\.jsp$ $1.html permanent;
	rewrite ^([^.]*)\.apk$ $1.html permanent;
}
# End: Redirect all extensions to html
