# invoke rewrite engine
RewriteEngine On
RewriteBase /

Options -Indexes
<IfModule mod_negotiation.c>
	Options -MultiViews
</IfModule>

# Redirect to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Add a trailing slash (/) to a URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.[A-Za-z0-9]*$
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]

# Create pretty URLs
RewriteRule ^([^/]+)/$ $1.html [S=9]
RewriteRule ^([^/]+)/([^/]+)/$ $1/$2.html [S=8]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3.html [S=7]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4.html [S=6]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5.html [S=5]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6.html [S=4]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7.html [S=3]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7/$8.html [S=2]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7/$8/$9.html [S=1]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7/$8/$9/$10.html

# Specific redirections
RewriteRule ^index.html$ / [L,R=301]
RewriteCond %{QUERY_STRING} ^reqp\=1&reqr\=$
RewriteRule ^[\/]?$ reqp_1_reqr/? [L,R=301]
RewriteCond %{QUERY_STRING} ^s\=\%7Bsearch_term_string\%7D$
RewriteRule ^[\/]?$ s_{search_term_string}/? [L,R=301]
RewriteCond %{QUERY_STRING} ^getlist\=country&current\=91$
RewriteRule ^extensions\/ensamble_extension\/ajax\/country\.php$ extensions/ensamble_extension/ajax/country_getlist_country_current_91/? [L,R=301]
RewriteRule ^news\/page\=2.html$ news/page_2/? [L,R=301]
RewriteRule ^news\/page\=3.html$ news/page_3/? [L,R=301]
RewriteRule ^news\/page\=4.html$ news/page_4/? [L,R=301]
RewriteCond %{QUERY_STRING} ^q\=L3MkWGAkYGR4Amt2AGp3ZwN0AGN4AwZkZQDyZwMaWGAkAGNjZFHlAzHyZ3RyZwMhWGAkZPHlAzZyZ3RjWGV2MJLyZ3RjWGV2MvHmpFHlAzIaWGAkZwNkAwN1ZmNjAwN3AGZyZwMwrFHmpGRyZwM0MlHmpGVyZwM4WGAkWGV2oabyZ3RjWGV2MaNyZ3RjWGV2nT5aWGAkZFHlAaEzWGAkAvHlAaOjWGAknTLyZwMkMFHmpJ5zYKSyqaRgLzVgZGt4AGpkAQR4AwH0ZQt5APHlAzMapPHmpGN\=\-1$
RewriteRule ^img\.aspx$ files/lAzMapPHmpGN_-1_html_s34nvd8pqimpepvzua4z5h/? [L,R=301]

# Redirect all extensions to html
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.shtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.phtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.jhtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.htm$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.php$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.aspx$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.asp$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.jsp$ $1.html [L,NC,R=301]
# End: Redirect all extensions to html
