ecshop中iis/apache伪静态规则配置示例
伪静态是现在网站建设技术中一门高常用的技术了,我们可以利用伪静态来实现网站像php一样更新全部自动更新,修改模板所有页面一并修改了,下文我们一起来看看ecshop中iis/apache伪静态规则配置示例.
apache下的伪静态规则范例
复制下面这段代码,然后存为 .htaccess 放到站点的根目录下面就行了,请确保您的空间/服务器是安装的apache,如果是iis,请参考代潇瑞博客中的 ecshop在iis下的伪静态规则范例,代码如下:
- <FilesMatch "\.(bak|inc|lib|sh|tpl|lbi|dwt)$">
- order deny,allow
- deny from all
- </FilesMatch>
-
- RewriteEngine On
- RewriteBase /
-
- # direct one-word access
- RewriteRule ^index\.html$ index\.php [L]
- RewriteRule ^category$ index\.php [L]
-
- # access any object by its numeric identifier
- RewriteRule ^feed-c([0-9]+)\.xml$ feed\.php\?cat=$1 [L]
- RewriteRule ^feed-b([0-9]+)\.xml$ feed\.php\?brand=$1 [L]
- RewriteRule ^feed-type([^-]+)\.xml$ feed\.php\?type=$1 [L]
- RewriteRule ^feed\.xml$ feed\.php [L]
-
- RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$ category\.php\?id=$1&brand=$2&page=$3 [QSA,L]
- RewriteRule ^category-([0-9]+)-b([0-9]+)(.*)\.html$ category\.php\?id=$1&brand=$2 [QSA,L]
- RewriteRule ^category-([0-9]+)(.*)\.html$ category\.php\?id=$1 [QSA,L]
-
- RewriteRule ^goods-([0-9a-zA-Z_]+)-([0-9]+)(.*)\.html$ goods\.php\?id=$2 [QSA,L]
- RewriteRule ^goods-([0-9]+)(.*)\.html$ goods\.php\?id=$1 [QSA,L]
-
- RewriteRule ^article_cat-([0-9]+)-([0-9]+)(.*)\.html$ article_cat\.php\?id=$1&page=$2 [QSA,L]
- RewriteRule ^article_cat-([0-9]+)(.*)\.html$ article_cat\.php\?id=$1 [QSA,L]
- RewriteRule ^article-([0-9]+)(.*)\.html$ article\.php\?id=$1 [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 ^brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html brand\.php\?id=$1&cat=$2&page=$3 [QSA,L]
- RewriteRule ^brand-([0-9]+)-c([0-9]+)(.*)\.html brand\.php\?id=$1&cat=$2 [QSA,L]
- RewriteRule ^brand-([0-9]+)(.*)\.html brand\.php\?id=$1 [QSA,L]
-
- RewriteRule ^tag-(.*)\.html search\.php\?keywords=$1 [QSA,L]
- RewriteRule ^snatch-([0-9]+)\.html$ snatch\.php\?id=$1 [QSA,L]
- RewriteRule ^group_buy-([0-9]+)\.html$ group_buy\.php\?act=view&id=$1 [QSA,L]
- RewriteRule ^auction-([0-9]+)\.html$ auction\.php\?act=view&id=$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>