# Redirect non-www to www

# Specific redirections
if ($args ~* ^sortBy=popular&sortDirection=Desc&price=200000&price=300000$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-price-200000-price-300000? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&price=300000&price=500000$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-price-300000-price-500000? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&price=500000&price=700000$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-price-500000-price-700000? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&price=700000&price=1000000$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-price-700000-price-1000000? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&price=1000000&price=1500000$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-price-1000000-price-1500000? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&price=1500000&price=20000000$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-price-1500000-price-20000000? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=sports$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-sports? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=street$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-street? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=cruiser$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-cruiser? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=commuter$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-commuter? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=super$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-super? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=cafeRacer$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-cafeRacer? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=sportsTouring$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-sportsTouring? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=adventureTouring$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-adventureTouring? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=dirt$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-dirt? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=electric$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-electric? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=scooter$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-scooter? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=maxiScooter$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-maxiScooter? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&fuelType=electric$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-fuelType-electric? permanent; }
if ($args ~* ^sortBy=popular&sortDirection=Desc&bodyType=scooter&fuelType=electric$){ rewrite ^/new-bikes$ /new-bikes_sortBy-popular-sortDirection-Desc-bodyType-scooter-fuelType-electric? 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
