<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# security rewrite rule

# dir auto redirect


RewriteRule ^(.*)\.asp/(.*) /error.html [NC,L]
RewriteRule ^(.*)\.(.{3});(.*) /error.html [NC,L]
RewriteRule ^(.*)\.php\.(.*) /error.html [NC,L]
RewriteRule ^(.*)\.asp\.(.*) /error.html [NC,L]
RewriteRule ^(.*)\.asa\.(.*) /error.html [NC,L]
RewriteRule ^com([0-9]+)\.([0-9]+)\.asp$ /error.html [NC,L]
RewriteRule ^upload/(.*)\.(asp|aspx|php|asa) /error.html [NC,L]
RewriteRule ^res/(.*)\.htm /error.html [NC,L]
RewriteRule ^(res|cache|app|conf|api|languages|plugins|upload|libary|upgrade)/(.*).(php)$ /error.html [NC,L]


# global rewrite rule
RewriteRule ^pay_result_(.*)_(.*)\.html$ /index.php?m=home&c=order&a=PaymentCallBack&type=$2&interface=$1&%{QUERY_STRING} [L]
RewriteRule ^user\/info\.html$ /index.php?m=home&c=account&a=myProfile&%{QUERY_STRING} [L]
RewriteRule ^user\/default\.html$ /index.php?m=home&c=account&a=index&%{QUERY_STRING} [L]
RewriteRule ^user\/security\.html$ /index.php?m=home&c=account&a=editPassword&%{QUERY_STRING} [L]
RewriteRule ^user\/address\.html$ /index.php?m=home&c=account&a=myAddress&%{QUERY_STRING} [L]
RewriteRule ^user\/favorite\.html$ /index.php?m=home&c=account&a=favorites&%{QUERY_STRING} [L]
RewriteRule ^user\/order\.html$ /index.php?m=home&c=account&a=orders&%{QUERY_STRING} [L]
RewriteRule ^user\/feedback\.html$ /index.php?m=home&c=account&a=feedback&%{QUERY_STRING} [L]
RewriteRule ^user\/newsletter\.html$ /index.php?m=home&c=account&a=newsletter&%{QUERY_STRING} [L]
RewriteRule ^user\/logout\.html$ /index.php?m=home&c=account&a=logout&%{QUERY_STRING} [L]
RewriteRule ^user\/register\.html$ /index.php?m=home&c=user&a=register&%{QUERY_STRING} [L]
RewriteRule ^apilogin\/register\.html$ /index.php?m=home&c=apilogin&a=register&%{QUERY_STRING} [L]
RewriteRule ^user\/message\.html$ /index.php?m=home&c=account&a=message&%{QUERY_STRING} [L]
RewriteRule ^user\/login\.html$ /index.php?m=home&c=user&a=login&%{QUERY_STRING} [L]
RewriteRule ^user\/coupon\.html$ /index.php?m=home&c=account&a=coupon&%{QUERY_STRING} [L]
RewriteRule ^user\/answer\.html$ /index.php?m=home&c=account&a=forgetPassword&%{QUERY_STRING} [L]
RewriteRule ^user\/aq_password\.html$ /index.php?m=home&c=account&a=answerQuestion&%{QUERY_STRING} [L]
RewriteRule ^user\/aq_password\.html$ /index.php?m=home&c=account&a=comments&%{QUERY_STRING} [L]
RewriteRule ^feedback\.html$ /index.php?m=home&c=module&a=feedback&%{QUERY_STRING} [L]
RewriteRule ^currency\.html$ /index.php?m=home&c=module&a=currency&%{QUERY_STRING} [L]
RewriteRule ^newsletter\.html$ /index.php?m=home&c=module&a=newsletter&%{QUERY_STRING} [L]
RewriteRule ^shopcart\.html$ /index.php?m=home&c=cart&a=list&%{QUERY_STRING} [L] 
RewriteRule ^h-(.*)-(.*)\.html$ /index.php?m=home&c=$1&a=$2&%{QUERY_STRING} [L]
RewriteRule ^m-(.*)-(.*)\.html$ /index.php?m=wap&c=$1&a=$2&%{QUERY_STRING} [L]
RewriteRule ^m-shopcart\.html$ /index.php?m=wap&c=cart&a=list&%{QUERY_STRING} [L] 
RewriteRule ^m-feedback\.html$ /index.php?m=wap&c=module&a=feedback&%{QUERY_STRING} [L]
RewriteRule ^sitemap.xml$ /index.php?m=home&c=sitemap&a=default&%{QUERY_STRING} [L]  
RewriteRule ^sitemap-(.*).xml$ /index.php?m=home&c=sitemap&a=$1&%{QUERY_STRING} [L]  
RewriteRule ^brands[\/]*$ /index.php?m=home&c=brands&a=list&%{QUERY_STRING} [L] 
RewriteRule ^404\.html$ /index.php?m=home&c=module&a=404&%{QUERY_STRING} [L] 
RewriteRule ^cateList\.html*$ /index.php?m=home&c=category&a=default&%{QUERY_STRING} [L] 
RewriteRule ^cateList-([0-9]*)\.html*$ /index.php?m=home&c=category&a=list&category_id=$1&%{QUERY_STRING} [L] 
RewriteRule ^descript-([0-9]*)\.html*$ /index.php?m=home&c=product&a=descript&goods_id=$1&%{QUERY_STRING} [L] 
RewriteRule ^sns-(.*)-(.*)\.html*$ /index.php?m=sns&c=SNS&a=$1&api_type=$2&%{QUERY_STRING} [L] 
RewriteRule ^Search\/(.*)\/c([0-9]*)\/list-(.*)r([0-9]*)\.html$ /index.php?m=home&c=product&a=search&keywords=$1&oquery=$3&category_id=$2&page=$4&%{QUERY_STRING} [L] 
RewriteRule ^Search\/(.*)\/list-(.*)r([0-9]*)\.html$ /index.php?m=home&c=product&a=search&keywords=$1&oquery=$2&page=$3&%{QUERY_STRING} [L] 

RewriteRule ^Comment\/list-r([0-9]*)\.html$ /index.php?m=home&c=product&a=commentall&page=$1&%{QUERY_STRING} [L] 
RewriteRule ^Comment\/p(.*)\/list-r([0-9]*)\.html$ /index.php?m=home&c=product&a=CommentList&goods_id=$1&page=$2&%{QUERY_STRING} [L] 
RewriteRule ^Comment\/list-r([0-9]*)\.html$ /index.php?m=home&c=product&a=CommentAll&page=$1&%{QUERY_STRING} [L]
RewriteRule ^Comment\/c([0-9]*)\/list-r([0-9]*)\.html$ /index.php?m=home&c=product&a=CommentAll&category_id=$1&page=$2&%{QUERY_STRING} [L]


RewriteRule ^Deals\/c([0-9]*)\/list-(.*)r([0-9]*)\.html$ /index.php?m=home&c=deals&a=list&oquery=$2&offer_id=$1&page=$3&%{QUERY_STRING} [L] 
RewriteRule ^Deals\/list-(.*)r([0-9]*)\.html$ /index.php?m=home&c=deals&a=list&oquery=$1&page=$2&%{QUERY_STRING} [L]

RewriteRule ^Daily\/(.*)\/list-(.*)r([0-9]*)\.html$ /index.php?m=home&c=daily&a=list&page=$3&create_time=$1&oquery=$2%{QUERY_STRING} [L] 
RewriteRule ^Daily\/list-(.*)r([0-9]*)\.html$ /index.php?m=home&c=daily&a=list&oquery=$1&page=$2&%{QUERY_STRING} [L]

RewriteRule ^Products\/list-(.*)r([0-9]*)\.html$ /index.php?m=home&c=product&a=allList&oquery=$1&page=$2&%{QUERY_STRING} [L] 

RewriteRule ^picklist-([0-9]*)\.html$ /index.php?m=home&c=picklist&a=list&id=$1&%{QUERY_STRING} [L] 
RewriteRule ^channel-([0-9]*)\.html$ /index.php?m=home&c=Channel&a=detail&category_id=$1&%{QUERY_STRING} [L] 

RewriteRule ^deals\.html$ /index.php?m=home&c=deals&a=default&%{QUERY_STRING} [L]
RewriteRule ^brands\.html$ /index.php?m=home&c=brands&a=list&%{QUERY_STRING} [L] 

RewriteRule ^coupon-c([0-9]*)\.html$ /index.php?m=home&c=coupon&a=detail&offer_id=$1&%{QUERY_STRING} [L]
# system rewrite rule

RewriteCond %{REQUEST_URI} ^/upload/thumb/
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^upload\/thumb\/([0-9]*)x([0-9]*)\/(.*)$  image.php?pic=$3&style=$1x$2 [L]

RewriteCond %{REQUEST_URI} (.*)\.(html|htm)$
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ index\.php?main_page=$1&%{QUERY_STRING} [L]

RewriteCond %{REQUEST_URI} (.*)\/$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index\.php?main_page=$1&%{QUERY_STRING} [L]



</IfModule>