# invoke rewrite engine
RewriteEngine On
RewriteBase /

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

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

# Prevent scraping from archive for free demo
RewriteCond %{HTTP_USER_AGENT} (ia_archiver) [NC]
RewriteRule . - [F,L]

# Specific redirections
RewriteRule ^index\.html$ / [L,R=301]
RewriteCond %{QUERY_STRING} ^route=account/register$
RewriteRule ^index\.php$ index_route-account_register [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/login$
RewriteRule ^index\.php$ index_route-account_login [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/wishlist$
RewriteRule ^index\.php$ index_route-account_wishlist [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=information/ordertracking$
RewriteRule ^index\.php$ index_route-information_ordertracking [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=checkout/cart$
RewriteRule ^index\.php$ index_route-checkout_cart [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=checkout/checkout$
RewriteRule ^index\.php$ index_route-checkout_checkout [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule ^index\.php$ index_route-common_home [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=product/category&path=153_166$
RewriteRule ^index\.php$ index_route-product_category-path-153_166 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=product/category&path=153_169$
RewriteRule ^index\.php$ index_route-product_category-path-153_169 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=product/category&path=153_165$
RewriteRule ^index\.php$ index_route-product_category-path-153_165 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=product/category&path=153_167$
RewriteRule ^index\.php$ index_route-product_category-path-153_167 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=product/category&path=153_171$
RewriteRule ^index\.php$ index_route-product_category-path-153_171 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/return/add$
RewriteRule ^index\.php$ index_route-account_return_add [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=information/sitemap$
RewriteRule ^index\.php$ index_route-information_sitemap [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=product/manufacturer$
RewriteRule ^index\.php$ index_route-product_manufacturer [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=product/special$
RewriteRule ^index\.php$ index_route-product_special [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/order$
RewriteRule ^index\.php$ index_route-account_order [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/newsletter$
RewriteRule ^index\.php$ index_route-account_newsletter [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=common/currency/currency$
RewriteRule ^index\.php$ index_route-common_currency_currency [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=common/footer/accept$
RewriteRule ^index\.php$ index_route-common_footer_accept [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=information/information/agree&information_id=3$
RewriteRule ^index\.php$ index_route-information_information_agree-information_id-3 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/forgotten$
RewriteRule ^index\.php$ index_route-account_forgotten [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/address$
RewriteRule ^index\.php$ index_route-account_address [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/download$
RewriteRule ^index\.php$ index_route-account_download [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/recurring$
RewriteRule ^index\.php$ index_route-account_recurring [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/reward$
RewriteRule ^index\.php$ index_route-account_reward [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/return$
RewriteRule ^index\.php$ index_route-account_return [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/transaction$
RewriteRule ^index\.php$ index_route-account_transaction [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=account/register/customfield&customer_group_id=$
RewriteRule ^index\.php$ index_route-account_register_customfield-customer_group_id [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^route=tool/upload$
RewriteRule ^index\.php$ index_route-tool_upload [L,R=301,QSD]

# Create pretty URLs
DirectorySlash Off

RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ %1 [NC,L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)/$
RewriteRule ^(.*)/$ $1 [NC,L,R=301]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
# End: Create pretty URLs

# 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]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.apk$ $1.html [L,NC,R=301]
# End: Redirect all extensions to html
