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

# Specific redirections
if ($args ~* ^valid=false$){ rewrite ^/ds_login\.asp$ /ds_login_valid-false/? permanent; }
if ($args ~* ^pid=1$){ rewrite ^/p_parts\.asp$ /p_parts_pid-1/? permanent; }
if ($args ~* ^pid=2$){ rewrite ^/p_parts\.asp$ /p_parts_pid-2/? permanent; }
if ($args ~* ^pid=3$){ rewrite ^/p_parts\.asp$ /p_parts_pid-3/? permanent; }
if ($args ~* ^cid=1$){ rewrite ^/p_products\.asp$ /p_products_cid-1/? permanent; }
if ($args ~* ^cid=2$){ rewrite ^/p_products\.asp$ /p_products_cid-2/? permanent; }
if ($args ~* ^cid=3$){ rewrite ^/p_products\.asp$ /p_products_cid-3/? permanent; }
if ($args ~* ^cid=4$){ rewrite ^/p_products\.asp$ /p_products_cid-4/? permanent; }
if ($args ~* ^pid=1$){ rewrite ^/p_productsdetails\.asp$ /p_productsdetails_pid-1/? permanent; }
if ($args ~* ^pid=2$){ rewrite ^/p_productsdetails\.asp$ /p_productsdetails_pid-2/? permanent; }
if ($args ~* ^pid=3$){ rewrite ^/p_productsdetails\.asp$ /p_productsdetails_pid-3/? permanent; }
if ($args ~* ^pid=5$){ rewrite ^/p_productsdetails\.asp$ /p_productsdetails_pid-5/? permanent; }
if ($args ~* ^pid=6$){ rewrite ^/p_productsdetails\.asp$ /p_productsdetails_pid-6/? permanent; }
if ($args ~* ^pid=7$){ rewrite ^/p_productsdetails\.asp$ /p_productsdetails_pid-7/? permanent; }
if ($args ~* ^pid=8$){ rewrite ^/p_productsdetails\.asp$ /p_productsdetails_pid-8/? permanent; }
if ($args ~* ^pid=9$){ rewrite ^/p_productsdetails\.asp$ /p_productsdetails_pid-9/? permanent; }
if ($args ~* ^sid=1$){ rewrite ^/p_service\.asp$ /p_service_sid-1/? permanent; }
if ($args ~* ^sid=3$){ rewrite ^/p_service\.asp$ /p_service_sid-3/? permanent; }
if ($args ~* ^i=DSCF0018\.JPG&w=175$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-DSCF0018_JPG-w-175/? permanent; }
if ($args ~* ^i=DSCF0018\.JPG&w=80$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-DSCF0018_JPG-w-80/? permanent; }
if ($args ~* ^i=flow3\.JPG&w=100$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-flow3_JPG-w-100/? permanent; }
if ($args ~* ^i=kira\.GIF&w=100$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-kira_GIF-w-100/? permanent; }
if ($args ~* ^i=kira\.GIF&w=54$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-kira_GIF-w-54/? permanent; }
if ($args ~* ^i=marvel\.GIF&w=100$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-marvel_GIF-w-100/? permanent; }
if ($args ~* ^i=mazak\+logo\(2\)\.jpg&w=100$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-mazak-logo(2)_jpg-w-100/? permanent; }
if ($args ~* ^i=mycrona\.jpg&w=100$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-mycrona_jpg-w-100/? permanent; }
if ($args ~* ^i=Nexus\+200\.JPG&w=175$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-Nexus-200_JPG-w-175/? permanent; }
if ($args ~* ^i=star3\.GIF&w=100$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-star3_GIF-w-100/? permanent; }
if ($args ~* ^i=Sunset\.jpg&w=125$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-Sunset_jpg-w-125/? permanent; }
if ($args ~* ^i=Sunset\.jpg&w=225$){ rewrite ^/thumbimg\.asp$ /thumbimg_i-Sunset_jpg-w-225/? 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
