你现在的位置:首页 > PHP网站建设知识库 > PrestaShop > 正文

PrestaShop在IIS上的伪静态规则

ISS的伪静态相信大家都知道。安装好prestashop后,在根目录下会有一个.htaccess文件,.htaccess只针对apache平台有效,在windows服务器下不起作用,因为如果网站是部署在windows服务器上面,起作用的是IIS的伪静态规则,相应内容应该写在web.config这个配置文件中,我们应该如何把.htaccess的伪静态规则转换成IIS兼容的规则呢?

\

以下是转换好的IIS伪静态规则,欢迎朋友们测试。

 

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 
<rewrite> 
<outboundRules> 
<preConditions> 
<preCondition name="ResponseIsHtml1"> 
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> 
</preCondition> 
</preConditions> 
</outboundRules> 
<rules> 
<clear /> 
<rule name="product"> 
<match url="([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" /> 
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> 
<action type="Rewrite" url="product.php?id_product={R:2}" /> 
</rule> 
<rule name="product home"> 
<match url="([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" /> 
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> 
<action type="Rewrite" url="product.php?id_product={R:1}{R:3}" /> 
</rule> 
<rule name="images"> 
<match url="([a-z0-9]+)-([a-z0-9]+)(-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*).jpg" /> 
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> 
<action type="Rewrite" url="/img/p/{R:1}-{R:2}{R:3}.jpg" appendQueryString="false" /> 
</rule> 
<rule name="image1"> 
<match url="([0-9]+)-([0-9]+)/([_a-zA-Z0-9-]*).jpg" /> 
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> 
<action type="Rewrite" url="/img/p/{R:1}-{R:2}.jpg" /> 
</rule> 
<rule name="Category" enabled="true"> 
<match url="^([0-9]+)\-([a-zA-Z0-9-]*)" /> 
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"> 
</conditions> 
<action type="Rewrite" url="category.php?id_category={R:1}" /> 
</rule> 
</rules> 
</rewrite> 
</system.webServer> 
</configuration>