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

# Specific redirections
if ($args ~* ^action=register$){ rewrite ^/my-account/?$ /my-account/action-register/? permanent; }
if ($args ~* ^login=true&type=forgot-password$){ rewrite ^//?$ /login-true-type-forgot-password/? permanent; }
if ($args ~* ^login=true$){ rewrite ^//?$ /login-true/? permanent; }
if ($args ~* ^orderby=menu_order$){ rewrite ^/product-category/toys/?$ /product-category/toys/orderby-menu_order/? permanent; }
if ($args ~* ^orderby=popularity$){ rewrite ^/product-category/toys/?$ /product-category/toys/orderby-popularity/? permanent; }
if ($args ~* ^orderby=rating$){ rewrite ^/product-category/toys/?$ /product-category/toys/orderby-rating/? permanent; }
if ($args ~* ^orderby=date$){ rewrite ^/product-category/toys/?$ /product-category/toys/orderby-date/? permanent; }
if ($args ~* ^orderby=price$){ rewrite ^/product-category/toys/?$ /product-category/toys/orderby-price/? permanent; }
if ($args ~* ^orderby=price-desc$){ rewrite ^/product-category/toys/?$ /product-category/toys/orderby-price-desc/? permanent; }
if ($args ~* ^orderby=menu_order$){ rewrite ^/product-category/toys/rocker/?$ /product-category/toys/rocker/orderby-menu_order/? permanent; }
if ($args ~* ^orderby=popularity$){ rewrite ^/product-category/toys/rocker/?$ /product-category/toys/rocker/orderby-popularity/? permanent; }
if ($args ~* ^orderby=rating$){ rewrite ^/product-category/toys/rocker/?$ /product-category/toys/rocker/orderby-rating/? permanent; }
if ($args ~* ^orderby=date$){ rewrite ^/product-category/toys/rocker/?$ /product-category/toys/rocker/orderby-date/? permanent; }
if ($args ~* ^orderby=price$){ rewrite ^/product-category/toys/rocker/?$ /product-category/toys/rocker/orderby-price/? permanent; }
if ($args ~* ^orderby=price-desc$){ rewrite ^/product-category/toys/rocker/?$ /product-category/toys/rocker/orderby-price-desc/? permanent; }
if ($args ~* ^action=register$){ rewrite ^/arian/?$ /arian/action-register/? permanent; }
if ($args ~* ^add_to_wishlist=5167$){ rewrite ^/product-category/toys/childrens-bedroom-furniture/?$ /product-category/toys/childrens-bedroom-furniture/add_to_wishlist-5167/? permanent; }
if ($args ~* ^add_to_wishlist=5176$){ rewrite ^/product-category/toys/childrens-bedroom-furniture/?$ /product-category/toys/childrens-bedroom-furniture/add_to_wishlist-5176/? permanent; }
if ($args ~* ^login=true$){ rewrite ^/product-category/toys/childrens-bedroom-furniture/?$ /product-category/toys/childrens-bedroom-furniture/login-true/? 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
