如何设置伪静态?
开启伪静态 店铺商品链接以http://abc.com/shop/1的格式显示;关闭伪静态 短链以http://abc.com/shop?id=1的格式显示
IIS环境
在网站根目录建一个文件,起名为web.config,并将以下内容复制进去
<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”Rewrite Rule 0″>
<match url=”^shop/([0-9]*)$” />
<action type=”Rewrite” url=”shop/index.php?id={R:1}” />
</rule>
<rule name=”Rewrite Rule 1″>
<match url=”^(.*).html$” />
<action type=”Rewrite” url=”index.php?type={R:1}” />
</rule>
<rule name=”Rewrite Rule 2″>
<match url=”^(.*)-([0-9]*).html$” />
<action type=”Rewrite” url=”index.php?type={R:1}&id={R:2}” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
apache环境
在网站根目录建一个文件,起名为.htaccess,并将以下内容复制进去
RewriteEngine On
RewriteRule ^shop/([0-9]*)$ shop/index.php?id=$1
RewriteRule ^(.*).html$ index.php?type=$1;
RewriteRule ^(.*)-([0-9]*).html$ index.php?type=$1&id=$2;
Nginx环境
在服务器相关位置设置
rewrite ^/shop/([0-9]*)$ /shop/index.php?id=$1;
rewrite ^/(.*).html$ /index.php?type=$1;
rewrite ^/(.*)-([0-9]*).html$ /index.php?type=$1&id=$2;