# Redirect non-www to www

# Specific redirections
if ($args ~* ^route=account/register$){ rewrite ^/index\.php$ /index_route-account_register? permanent; }
if ($args ~* ^route=account/login$){ rewrite ^/index\.php$ /index_route-account_login? permanent; }
if ($args ~* ^route=account/wishlist$){ rewrite ^/index\.php$ /index_route-account_wishlist? permanent; }
if ($args ~* ^route=information/ordertracking$){ rewrite ^/index\.php$ /index_route-information_ordertracking? permanent; }
if ($args ~* ^route=checkout/cart$){ rewrite ^/index\.php$ /index_route-checkout_cart? permanent; }
if ($args ~* ^route=checkout/checkout$){ rewrite ^/index\.php$ /index_route-checkout_checkout? permanent; }
if ($args ~* ^route=common/home$){ rewrite ^/index\.php$ /index_route-common_home? permanent; }
if ($args ~* ^route=product/category&path=153_166$){ rewrite ^/index\.php$ /index_route-product_category-path-153_166? permanent; }
if ($args ~* ^route=product/category&path=153_169$){ rewrite ^/index\.php$ /index_route-product_category-path-153_169? permanent; }
if ($args ~* ^route=product/category&path=153_165$){ rewrite ^/index\.php$ /index_route-product_category-path-153_165? permanent; }
if ($args ~* ^route=product/category&path=153_167$){ rewrite ^/index\.php$ /index_route-product_category-path-153_167? permanent; }
if ($args ~* ^route=product/category&path=153_171$){ rewrite ^/index\.php$ /index_route-product_category-path-153_171? permanent; }
if ($args ~* ^route=account/return/add$){ rewrite ^/index\.php$ /index_route-account_return_add? permanent; }
if ($args ~* ^route=information/sitemap$){ rewrite ^/index\.php$ /index_route-information_sitemap? permanent; }
if ($args ~* ^route=product/manufacturer$){ rewrite ^/index\.php$ /index_route-product_manufacturer? permanent; }
if ($args ~* ^route=product/special$){ rewrite ^/index\.php$ /index_route-product_special? permanent; }
if ($args ~* ^route=account/order$){ rewrite ^/index\.php$ /index_route-account_order? permanent; }
if ($args ~* ^route=account/newsletter$){ rewrite ^/index\.php$ /index_route-account_newsletter? permanent; }
if ($args ~* ^route=common/currency/currency$){ rewrite ^/index\.php$ /index_route-common_currency_currency? permanent; }
if ($args ~* ^route=common/footer/accept$){ rewrite ^/index\.php$ /index_route-common_footer_accept? permanent; }
if ($args ~* ^route=information/information/agree&information_id=3$){ rewrite ^/index\.php$ /index_route-information_information_agree-information_id-3? permanent; }
if ($args ~* ^route=account/forgotten$){ rewrite ^/index\.php$ /index_route-account_forgotten? permanent; }
if ($args ~* ^route=account/address$){ rewrite ^/index\.php$ /index_route-account_address? permanent; }
if ($args ~* ^route=account/download$){ rewrite ^/index\.php$ /index_route-account_download? permanent; }
if ($args ~* ^route=account/recurring$){ rewrite ^/index\.php$ /index_route-account_recurring? permanent; }
if ($args ~* ^route=account/reward$){ rewrite ^/index\.php$ /index_route-account_reward? permanent; }
if ($args ~* ^route=account/return$){ rewrite ^/index\.php$ /index_route-account_return? permanent; }
if ($args ~* ^route=account/transaction$){ rewrite ^/index\.php$ /index_route-account_transaction? permanent; }
if ($args ~* ^route=account/register/customfield&customer_group_id=$){ rewrite ^/index\.php$ /index_route-account_register_customfield-customer_group_id? permanent; }
if ($args ~* ^route=tool/upload$){ rewrite ^/index\.php$ /index_route-tool_upload? 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
