apache下的伪静态规则范例
复制下面这段代码,然后存为 .htaccess 放到站点的根目录下面就行了。(请确保您的空间/服务器是安装的apache,如果是iis,请参考代潇瑞博客中的 ecshop在iis下的伪静态规则范例)
代码如下 | 复制代码 |
<FilesMatch "\.(bak|inc|lib|sh|tpl|lbi|dwt)$"> order deny,allow deny from all </FilesMatch> RewriteEngine On # direct one-word access # access any object by its numeric identifier RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$ category\.php\?id=$1&brand=$2&page=$3 [QSA,L] RewriteRule ^goods-([0-9a-zA-Z_]+)-([0-9]+)(.*)\.html$ goods\.php\?id=$2 [QSA,L] RewriteRule ^article_cat-([0-9]+)-([0-9]+)(.*)\.html$ article_cat\.php\?id=$1&page=$2 [QSA,L] RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html brand\.php\?id=$1&cat=$2&page=$3&sort=$4&order=$5 [QSA,L] RewriteRule ^tag-(.*)\.html search\.php\?keywords=$1 [QSA,L] |
iis下的伪静态规则范例
复制下面的代码,存为 web.config 放到站点的根目录下面就行了。(请确保您的空间/服务器是安装的iis,如果是apache,请参考代潇瑞博客中的 ecshop在apache下的伪静态规则范例)
代码如下 | 复制代码 |
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="index"> <match url="^index.html" /> <action type="Rewrite" url="index.php" /> </rule> <rule name="category"> <match url="^(.*/)*category.html" /> <action type="Rewrite" url="{R:1}/category.php" /> </rule> <rule name="category0"> <match url="^(.*/)*category-([0-9]+).html" /> <action type="Rewrite" url="{R:1}/category.php\?id={R:2}" /> </rule> <rule name="category1"> <match url="^(.*/)*category-([0-9]+)-([0-9]+)-(\w+).html" /> <action type="Rewrite" url="{R:1}/category.php\?id={R:2}&page={R:3}" /> </rule> <rule name="brands"> <match url="^(.*/)*brands-([0-9]+).html" /> <action type="Rewrite" url="{R:1}/brands.php\?id={R:2}" /> </rule> <rule name="article"> <match url="^(.*/)*article-([0-9]+).html" /> <action type="Rewrite" url="{R:1}/article.php\?id={R:2}" /> </rule> <rule name="article_cat"> <match url="^(.*/)*article_cat-([0-9]+).html" /> <action type="Rewrite" url="{R:1}/article_cat.php\?id={R:2}" /> </rule> <rule name="article_cat_page"> <match url="^(.*/)*article_cat-([0-9]+)-([0-9]+).html" /> <action type="Rewrite" url="{R:1}/article_cat.php\?id={R:2}&page={R:3}" /> </rule> <rule name="goods"> <match url="^(.*/)*goods-([0-9]+).html" /> <action type="Rewrite" url="{R:1}/goods.php\?id={R:2}" /> </rule> <rule name="contact"> <match url="^(.*/)*contact.html" /> <action type="Rewrite" url="{R:1}/contact.php" /> </rule> <rule name="search"> <match url="^(.*/)*search-([a-zA-Z]+).html" /> <action type="Rewrite" url="{R:1}/search.php\?intro={R:2}" /> </rule> <rule name="maps"> <match url="^(.*/)*maps.html" /> <action type="Rewrite" url="{R:1}/maps.php" /> </rule> </rules> </rewrite> </system.webServer> </configuration> |