# Redirect non-www to www

# Specific redirections
if ($args ~* ^route=common/home$){ rewrite ^/index\.php$ /index_route-common_home? permanent; }
if ($args ~* ^route=account/login$){ rewrite ^/index\.php$ /index_route-account_login? permanent; }
if ($args ~* ^route=account/register$){ rewrite ^/index\.php$ /index_route-account_register? permanent; }
if ($args ~* ^route=account/wishlist$){ rewrite ^/index\.php$ /index_route-account_wishlist? permanent; }
if ($args ~* ^route=account/account$){ rewrite ^/index\.php$ /index_route-account_account? 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=information/information&information_id=31$){ rewrite ^/index\.php$ /index_route-information_information-information_id-31? permanent; }
if ($args ~* ^route=product/category&path=67$){ rewrite ^/index\.php$ /index_route-product_category-path-67? permanent; }
if ($args ~* ^route=product/category&path=68$){ rewrite ^/index\.php$ /index_route-product_category-path-68? permanent; }
if ($args ~* ^route=product/category&path=70$){ rewrite ^/index\.php$ /index_route-product_category-path-70? permanent; }
if ($args ~* ^route=product/manufacturer$){ rewrite ^/index\.php$ /index_route-product_manufacturer? permanent; }
if ($args ~* ^route=information/news$){ rewrite ^/index\.php$ /index_route-information_news? permanent; }
if ($args ~* ^route=account/voucher$){ rewrite ^/index\.php$ /index_route-account_voucher? permanent; }
if ($args ~* ^route=account/order$){ rewrite ^/index\.php$ /index_route-account_order? permanent; }
if ($args ~* ^route=module/language$){ rewrite ^/index\.php$ /index_route-module_language? permanent; }
if ($args ~* ^route=module/currency$){ rewrite ^/index\.php$ /index_route-module_currency? 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/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/newsletter$){ rewrite ^/index\.php$ /index_route-account_newsletter? permanent; }
if ($args ~* ^route=account/recurring$){ rewrite ^/index\.php$ /index_route-account_recurring? permanent; }
if ($args ~* ^route=information/information/info&information_id=3$){ rewrite ^/index\.php$ /index_route-information_information_info-information_id-3? permanent; }
if ($args ~* ^route=account/register/country&country_id=$){ rewrite ^/index\.php$ /index_route-account_register_country-country_id? 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
