如何设置伪静态?
2020-02-17如果需要开启伪静态,请保证您的环境支持伪静态功能,如果不支持请联系空间商
1.进入后台-系统设置-基本设置-辅助功能,开启伪静态
2.在后台开启伪静态后,需要在网站根目录配置伪静态规则文件
IIS环境
在网站根目录建一个文件,起名为web.config,并将以下内容复制进去
----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="index1">
<match url="^(.*)-([0-9]*)-([0-9]*)-([0-9]*).html$" />
<action type="Rewrite" url="index.php?type={R:1}&id={R:2}&page={R:3}&M_id={R:4}"/>
</rule>
<rule name="index2">
<match url="^(.*)-([0-9]*).html$" />
<action type="Rewrite" url="index.php?type={R:1}&id={R:2}"/>
</rule>
<rule name="index3">
<match url="^(.*)-tag-(.*).html$" />
<action type="Rewrite" url="index.php?type={R:1}&tag={R:2}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
-----------------------------------------
apache环境
在网站根目录建一个文件,起名为.htaccess,并将以下内容复制进去
---------------------------------------------------------------------------
RewriteEngine On
RewriteRule ^(.*)-([0-9]*)-([0-9]*)-([0-9]*).html$ index.php?type=$1&id=$2&page=$3&M_id=$4
RewriteRule ^(.*)-([0-9]*).html$ index.php?type=$1&id=$2
RewriteRule ^(.*)-tag-(.*).html$ index.php?type=$1&tag=$2
------------------------------------------------------------------------------------
Nginx环境
在服务器相关位置设置
----------------------------------------------------------------------------
rewrite ^/(.*)-([0-9]*)-([0-9]*)-([0-9]*).html$ /index.php?type=$1&id=$2&page=$3&M_id=$4;
rewrite ^/(.*)-([0-9]*).html$ /index.php?type=$1&id=$2;
rewrite ^/(.*)-tag-(.*).html$ /index.php?type=$1&tag=$2;
-------------------------------------