# Add a trailing slash (/) to a URL
rewrite ^([^.]*[^/])$ $1/ permanent;

# Specific redirections
if ($args ~* ^mode=list$){ rewrite ^/order-coffee\.html$ /order-coffee_mode-list/? permanent; }
if ($args ~* ^dir=desc&order=position$){ rewrite ^/order-coffee\.html$ /order-coffee_dir-desc-order-position/? permanent; }
rewrite ^/catalog/product_compare/add/product/3/uenc/aHR0cDovL2NvZmZlZWZvcndhdGVyLmNvbS9vcmRlci1jb2ZmZWUuaHRtbA,,/form_key/fLfIdsfBLh3F2eLp$ /catalog/product_compare/add/product/3/uenc/aHR0cDovL2NvZmZlZWZvcndhdGVyLmNvbS9vcmRlci1jb2ZmZWUuaHRtbA--/form_key/fLfIdsfBLh3F2eLp/? permanent;
if ($args ~* ^price=10-$){ rewrite ^/order-coffee\.html$ /order-coffee_price-10-/? permanent; }
if ($args ~* ^manufacturer=7$){ rewrite ^/order-coffee\.html$ /order-coffee_manufacturer-7/? permanent; }
if ($args ~* ^coffeetype=5$){ rewrite ^/order-coffee\.html$ /order-coffee_coffeetype-5/? permanent; }
rewrite ^/checkout/cart/add/uenc/aHR0cDovL2NvZmZlZWZvcndhdGVyLmNvbS9vcmRlci1jb2ZmZWUuaHRtbA,,/product/3/form_key/fLfIdsfBLh3F2eLp$ /checkout/cart/add/uenc/aHR0cDovL2NvZmZlZWZvcndhdGVyLmNvbS9vcmRlci1jb2ZmZWUuaHRtbA--/product/3/form_key/fLfIdsfBLh3F2eLp/? 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
