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

RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^index.htm http://%1/ [R=301,L]

RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^index.html http://%1/ [R=301,L]

RewriteRule ^css(.*)$ /templates/css$1
RewriteRule ^font(.*)$ /templates/font$1
RewriteRule ^fonts(.*)$ /templates/fonts$1
RewriteRule ^images(.*)$ /templates/images$1
RewriteRule ^jquery(.*)$ /templates/jquery$1
RewriteRule ^js(.*)$ /templates/js$1
RewriteRule ^Scripts(.*)$ /templates/Scripts$1
RewriteBase /


#禁止讀取目錄中檔案列表
Options -Indexes


#404頁面
ErrorDocument 404 /404.php


#配置文件
RewriteRule config.xml$ error.php?error=404
RewriteRule config.php$ error.php?error=404


#首頁
RewriteRule ^index\.(htm|html|asp|aspx|jsp)$			index.php

#封鎖頁
RewriteRule ^home\.html     - [L]

#XML
RewriteRule ^sitemap.xml								sitemap.php
RewriteRule ^rss.xml									rss.php

#demo頁
RewriteRule ^demo.html$				demo.php
RewriteRule ^demo2.html$			demo2.php


#受保護的目錄
RewriteRule ^templates/webParts/ error.php?error=404
RewriteRule ^templates/([0-9]+)/ error.php?error=404
RewriteRule ^demo/ error.php?error=404
RewriteRule ^database/ error.php?error=404
RewriteRule ^admin/templates/ error.php?error=404


#WebSite Page Start
#article start /article/
RewriteRule ^article.html$								article.php
RewriteRule ^article-([a-zA-Z0-9\-_]+).html$			article.php?path=$1
#article end


#news start /news/
RewriteRule ^news.html$									news.php
RewriteRule ^news_([0-9]+).html$						news.php?p=$1
RewriteRule ^news([0-9]+).html$							news.php?id=$1
RewriteRule ^news([0-9]+)_([0-9]+).html$				news.php?id=$1&p=$2
RewriteRule ^news-([0-9]+).html$						news-detail.php?id=$1
#news end


#faq start /faq/
RewriteRule ^faq.html$									faq.php
RewriteRule ^faq_([0-9]+).html$							faq.php?p=$1
RewriteRule ^faq([0-9]+).html$							faq.php?id=$1
RewriteRule ^faq([0-9]+)_([0-9]+).html$					faq.php?id=$1&p=$2
RewriteRule ^faq-([0-9]+).html$							faq-detail.php?id=$1
#faq end


#product start /product/
RewriteRule ^product.html$								product.php
RewriteRule ^product_([0-9]+).html$						product.php?p=$1
RewriteRule ^product([0-9]+).html$						product.php?id=$1
RewriteRule ^product([0-9]+)_([0-9]+).html$				product.php?id=$1&p=$2
RewriteRule ^product-([0-9]+).html$						product-detail.php?id=$1
#product end


#book start /book/
RewriteRule ^book.html$									book.php
RewriteRule ^book_([0-9]+).html$						book.php?p=$1
RewriteRule ^book([0-9]+).html$							book.php?id=$1
RewriteRule ^book([0-9]+)_([0-9]+).html$				book.php?id=$1&p=$2
RewriteRule ^book-([0-9]+).html$						book-detail.php?id=$1
#book end


#contact start /contact/
RewriteRule ^contact.html$								contact.php
RewriteRule ^contact-([0-9]+).html$						contact.php?id=$1
#contact end


#order start /order/
RewriteRule ^order.html$								order.php
#order end


#no set page start
RewriteRule ^[a-zA-Z0-9\-_].html$						index.php
#no set page end


#WebSite Page End

#IP訪問限制