destoon之URL Rewrite(伪静态)设置方法详解
1、如果您的服务器支持.htaccess,则无需设置,网站根目录下的.htaccess已经设置好规则。
规则(参考http://download.destoon.com/rewrite/htaccess.txt)
#DestoonB2BRewriteRules ErrorDocument404/404.php RewriteEngineOn RewriteBase/ RewriteRule^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$/404.php RewriteRule^(.*)/file/(.*)\.php(.*)$/404.php RewriteRule^(.*)-htm-(.*)$$1.php?$2 RewriteRule^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$$1/show.php?itemid=$2&page=$4 RewriteRule^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$$1/list.php?catid=$2&page=$4 RewriteRule^(.*)/show/([0-9]+)/([0-9]+)?([/])?$$1/show.php?itemid=$2&page=$3 RewriteRule^(.*)/list/([0-9]+)/([0-9]+)?([/])?$$1/list.php?catid=$2&page=$3 RewriteRule^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$$1/list.php?catid=$3&page=$4 RewriteRule^(.*)/([a-z]+)/(.*)\.shtml$$1/$2/index.php?rewrite=$3 RewriteRule^(com)/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$index.php?homepage=$2&file=$3&rewrite=$4 RewriteRule^(com)/([a-z0-9_\-]+)/([a-z]+)([/])?$index.php?homepage=$2&file=$3 RewriteRule^(com)/([a-z0-9_\-]+)([/])?$index.php?homepage=$2
2、如果是Apache服务器:
Apache1.x的用户请检查conf/httpd.conf中是否存在如下两段代码:
LoadModulerewrite_modulelibexec/mod_rewrite.so AddModulemod_rewrite.c
Apache2.x的用户请检查conf/httpd.conf中是否存在如下一段代码:
LoadModulerewrite_modulemodules/mod_rewrite.so
如果存在,且以#开头,请删除#。然后在配置文件(通常就是conf/httpd.conf或者conf/extra/httpd-vhosts.conf)中加入如下代码。
此时请务必注意,如果网站使用通过虚拟主机来定义,请务必加到虚拟主机配置,即<VirtualHost>中去,如果加在虚拟主机配置外部将可能无法使用。改好后然后将Apache重启。
Apacheconf文件配置(参考http://download.destoon.com/rewrite/apache.txt)规则:
#DestoonB2BRewriteRules ErrorDocument404/404.php RewriteEngineOn RewriteBase/ RewriteRule^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$/404.php RewriteRule^(.*)/file/(.*)\.php(.*)$/404.php RewriteRule^(.*)-htm-(.*)$$1.php?$2 RewriteRule^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$$1/show.php?itemid=$2&page=$4 RewriteRule^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$$1/list.php?catid=$2&page=$4 RewriteRule^(.*)/show/([0-9]+)/([0-9]+)?([/])?$$1/show.php?itemid=$2&page=$3 RewriteRule^(.*)/list/([0-9]+)/([0-9]+)?([/])?$$1/list.php?catid=$2&page=$3 RewriteRule^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$$1/list.php?catid=$3&page=$4 RewriteRule^(.*)/([a-z]+)/(.*)\.shtml$$1/$2/index.php?rewrite=$3 RewriteRule^(.*)/com/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$$1/index.php?homepage=$2&file=$3&rewrite=$4 RewriteRule^(.*)/com/([a-z0-9_\-]+)/([a-z]+)([/])?$$1/index.php?homepage=$2&file=$3 RewriteRule^(.*)/com/([a-z0-9_\-]+)([/])?$$1/index.php?homepage=$2
3、Nginx规则(参考http://download.destoon.com/rewrite/nginx.txt):
rewrite^/(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$/404.phplast; rewrite^/(.*)/file/(.*)\.php(.*)$/404.phplast; rewrite^/(.*)-htm-(.*)$/$1.php?$2last; rewrite^/(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$/$1/show.php?itemid=$2&page=$4last; rewrite^/(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$/$1/list.php?catid=$2&page=$4last; rewrite^/(.*)/show/([0-9]+)/([0-9]+)?([/])?$/$1/show.php?itemid=$2&page=$3last; rewrite^/(.*)/list/([0-9]+)/([0-9]+)?([/])?$/$1/list.php?catid=$2&page=$3last; rewrite^/(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$/$1/list.php?catid=$3&page=$4last; rewrite^(.*)/([a-z]+)/(.*)\.shtml$$1/$2/index.php?rewrite=$3last; rewrite^/(com)/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$/index.php?homepage=$2&file=$3&rewrite=$4last; rewrite^/(com)/([a-z0-9_\-]+)/([a-z]+)([/])?$/index.php?homepage=$2&file=$3last; rewrite^/(com)/([a-z0-9_\-]+)([/])?$/index.php?homepage=$2last;
4、Zeus规则(参考http://download.destoon.com/rewrite/zeus.txt):
matchURLinto$with^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ ifmatchedthen setURL=/404.php endif matchURLinto$with^(.*)/file/(.*)\.php(.*)$ ifmatchedthen setURL=/404.php endif matchURLinto$with^(.*)-htm-(.*)$ ifmatchedthen setURL=$1.php?$2 endif matchURLinto$with^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ ifmatchedthen setURL=$1/show.php?itemid=$2&page=$4 endif matchURLinto$with^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ ifmatchedthen setURL=$1/list.php?catid=$2&page=$4 endif matchURLinto$with^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ ifmatchedthen setURL=$1/show.php?itemid=$2&page=$3 endif matchURLinto$with^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ ifmatchedthen setURL=$1/list.php?catid=$2&page=$3 endif matchURLinto$with^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$ ifmatchedthen setURL=$1/list.php?catid=$3&page=$4 endif matchURLinto$with^(.*)/([a-z]+)/(.*)\.shtml$ ifmatchedthen setURL=$1/$2/index.php?rewrite=$3 endif matchURLinto$with^(.*)/com/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$ ifmatchedthen setURL=$1/index.php?homepage=$2&file=$3&rewrite=$4 endif matchURLinto$with^(.*)/com/([a-z0-9_\-]+)/([a-z]+)([/])?$ ifmatchedthen setURL=$1/index.php?homepage=$2&file=$3 endif matchURLinto$with^(.*)/com/([a-z0-9_\-]+)([/])?$ ifmatchedthen setURL=$1/index.php?homepage=$2 endif
5、IIS6服务器
请下载http://download.destoon.com/rewrite/IIS_Rewrite.zip
规则已经设置好,按readme.txt文件内容进行操作
如果网站支持httpd.ini文件,请使用如下规则(参考http://download.destoon.com/rewrite/httpd.ini):
[ISAPI_Rewrite] #DestoonB2Bwww.destoon.com #3600=1hour CacheClockRate3600 RepeatLimit32 #Protecthttpd.iniandhttpd.parse.errorsfiles #fromaccessingthroughHTTP RewriteRule^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$/404\.php RewriteRule^(.*)/file/(.*)\.php(.*)$/404\.php RewriteRule^(.*)-htm-(.*)$$1\.php\?$2 RewriteRule^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$$1/show\.php\?itemid=$2&page=$4 RewriteRule^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$$1/list\.php\?catid=$2&page=$4 RewriteRule^(.*)/show/([0-9]+)/([0-9]+)?([/])?$$1/show\.php\?itemid=$2&page=$3 RewriteRule^(.*)/list/([0-9]+)/([0-9]+)?([/])?$$1/list\.php\?catid=$2&page=$3 RewriteRule^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$$1/list\.php\?catid=$3&page=$4 RewriteRule^(.*)/com/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$$1/index\.php\?homepage=$2&file=$3&rewrite=$4 RewriteRule^(.*)/com/([a-z0-9_\-]+)/([a-z]+)([/])?$$1/index\.php\?homepage=$2&file=$3 RewriteRule^(.*)/com/([a-z0-9_\-]+)([/])?$$1/index\.php\?homepage=$2 RewriteRule^(.*)/([a-z]+)/(.*)\.shtml$$1/$2/index\.php\?rewrite=$3
6、IIS7服务器
规则(参考http://download.destoon.com/rewrite/web.config.txt)为:
<?xmlversion="1.0"encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rulename="destoon_rewrite_0"> <matchurl="^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$"/> <actiontype="Rewrite"url="/404.php"/> </rule> <rulename="destoon_rewrite_1"> <matchurl="^(.*)/file/(.*)\.php(.*)$"/> <actiontype="Rewrite"url="/404.php"/> </rule> <rulename="destoon_rewrite_2"> <matchurl="^(.*)-htm-(.*)$"/> <actiontype="Rewrite"url="{R:1}.php?{R:2}"/> </rule> <rulename="destoon_rewrite_3"> <matchurl="^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$"/> <actiontype="Rewrite"url="{R:1}/show.php?itemid={R:2}&page={R:4}"/> </rule> <rulename="destoon_rewrite_4"> <matchurl="^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$"/> <actiontype="Rewrite"url="{R:1}/list.php?catid={R:2}&page={R:4}"/> </rule> <rulename="destoon_rewrite_5"> <matchurl="^(.*)/show/([0-9]+)/([0-9]+)?([/])?$"/> <actiontype="Rewrite"url="{R:1}/show.php?itemid={R:2}&page={R:3}"/> </rule> <rulename="destoon_rewrite_6"> <matchurl="^(.*)/list/([0-9]+)/([0-9]+)?([/])?$"/> <actiontype="Rewrite"url="{R:1}/list.php?catid={R:2}&page={R:3}"/> </rule> <rulename="destoon_rewrite_7"> <matchurl="^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$"/> <actiontype="Rewrite"url="{R:1}/list.php?catid={R:3}&page={R:4}"/> </rule> <rulename="destoon_rewrite_8"> <matchurl="^(com)/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$"/> <actiontype="Rewrite"url="index.php?homepage={R:2}&file={R:3}&rewrite={R:4}"/> </rule> <rulename="destoon_rewrite_9"> <matchurl="^(com)/([a-z0-9_\-]+)/([a-z]+)([/])?$"/> <actiontype="Rewrite"url="index.php?homepage={R:2}&file={R:3}"/> </rule> <rulename="destoon_rewrite_10"> <matchurl="^(com)/([a-z0-9_\-]+)([/])?$"/> <actiontype="Rewrite"url="index.php?homepage={R:2}"/> </rule> <rulename="destoon_rewrite_11"> <matchurl="^([a-z]+)/(.*)\.shtml$"/> <actiontype="Rewrite"url="{R:1}/index.php?rewrite={R:2}"/> </rule> </rules> </rewrite> </system.webServer> </configuration>
Rewrite生效后,请在网站后台=》网站设置=》SEO优化=》URLRewrite,选择“开启”提交。
然后进入各模块的模块设置“SEO设置”选择对应伪静态地址规则
选择“更新地址”提交即可。