主机怎么设置伪静态规则

主机怎么设置伪静态规则,第1张

discuzx2多服务器伪静态规则

其实是从discuz的背景中获得的。这是一个直接的伪静态规则。您可以根据您的服务器版本进行选择。如果是虚拟主机客户,需要咨询服务器提供商。

ApacheWebServer(独立主机用户)

复制代码代码如下:
<IfModulemod_rewrite.c>
RewriteEngineOn
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^(.*)/topic-(.+)\.html$$1/portal.php?mod=topic&topic=$2&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^(.*)/article-([0-9]+)-([0-9]+)\.html$$1/portal.php?mod=view&aid=$2&page=$3&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^(.*)/forum-(\w+)-([0-9]+)\.html$$1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$$1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^(.*)/group-([0-9]+)-([0-9]+)\.html$$1/forum.php?mod=group&fid=$2&page=$3&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^(.*)/space-(username|uid)-(.+)\.html$$1/home.php?mod=space&$2=$3&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^(.*)/blog-([0-9]+)-([0-9]+)\.html$$1/home.php?mod=space&uid=$2&do=blog&id=$3&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^(.*)/(fid|tid)-([0-9]+)\.html$$1/index.php?action=$2&value=$3&%1
</IfModule>

ApacheWebServer(虚拟主机用户)

复制代码代码如下:
#将RewriteEngine模式打开
RewriteEngineOn
#修改以下语句中的/discuz为你的论坛目录地址,如果程序放在根目录中,请将/discuz修改为/
RewriteBase/discuz
#Rewrite系统规则请勿修改
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^topic-(.+)\.html$portal.php?mod=topic&topic=$1&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^article-([0-9]+)-([0-9]+)\.html$portal.php?mod=view&aid=$1&page=$2&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^forum-(\w+)-([0-9]+)\.html$forum.php?mod=forumdisplay&fid=$1&page=$2&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^group-([0-9]+)-([0-9]+)\.html$forum.php?mod=group&fid=$1&page=$2&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^space-(username|uid)-(.+)\.html$home.php?mod=space&$1=$2&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^blog-([0-9]+)-([0-9]+)\.html$home.php?mod=space&uid=$1&do=blog&id=$2&%1
RewriteCond%{QUERY_STRING}^(.*)$
RewriteRule^archiver/(fid|tid)-([0-9]+)\.html$archiver/index.php?action=$1&value=$2&%1

IISWebServer(独立主机用户)

复制代码代码如下:
[ISAPI_Rewrite]
#3600=1hour
CacheClockRate3600
RepeatLimit32
#Protecthttpd.iniandhttpd.parse.errorsfiles
#fromaccessingthroughHTTP
RewriteRule^(.*)/topic-(.+)\.html(\?(.*))*$$1/portal\.php\?mod=topic&topic=$2&$4
RewriteRule^(.*)/article-([0-9]+)-([0-9]+)\.html(\?(.*))*$$1/portal\.php\?mod=view&aid=$2&page=$3&$5
RewriteRule^(.*)/forum-(\w+)-([0-9]+)\.html(\?(.*))*$$1/forum\.php\?mod=forumdisplay&fid=$2&page=$3&$5
RewriteRule^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html(\?(.*))*$$1/forum\.php\?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$6
RewriteRule^(.*)/group-([0-9]+)-([0-9]+)\.html(\?(.*))*$$1/forum\.php\?mod=group&fid=$2&page=$3&$5
RewriteRule^(.*)/space-(username|uid)-(.+)\.html(\?(.*))*$$1/home\.php\?mod=space&$2=$3&$5
RewriteRule^(.*)/blog-([0-9]+)-([0-9]+)\.html(\?(.*))*$$1/home\.php\?mod=space&uid=$2&do=blog&id=$3&$5
RewriteRule^(.*)/(fid|tid)-([0-9]+)\.html(\?(.*))*$$1/index\.php\?action=$2&value=$3&$5

IIS7WebServer(独立主机用户)

复制代码代码如下:
<rewrite>
<rules>
<rulename="portal_topic">
<matchurl="^(.*/)*topic-(.+).html\?*(.*)$"/>
<actiontype="Rewrite"url="{R:1}/portal.php\?mod=topic&amp;topic={R:2}&amp;{R:3}"/>
</rule>
<rulename="portal_article">
<matchurl="^(.*/)*article-([0-9]+)-([0-9]+).html\?*(.*)$"/>
<actiontype="Rewrite"url="{R:1}/portal.php\?mod=view&amp;aid={R:2}&amp;page={R:3}&amp;{R:4}"/>
</rule>
<rulename="forum_forumdisplay">
<matchurl="^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$"/>
<actiontype="Rewrite"url="{R:1}/forum.php\?mod=forumdisplay&amp;fid={R:2}&amp;page={R:3}&amp;{R:4}"/>
</rule>
<rulename="forum_viewthread">
<matchurl="^(.*/)*thread-([0-9]+)-([0-9]+)-([0-9]+).html\?*(.*)$"/>
<actiontype="Rewrite"url="{R:1}/forum.php\?mod=viewthread&amp;tid={R:2}&amp;extra=page%3D{R:4}&amp;page={R:3}&amp;{R:5}"/>
</rule>
<rulename="group_group">
<matchurl="^(.*/)*group-([0-9]+)-([0-9]+).html\?*(.*)$"/>
<actiontype="Rewrite"url="{R:1}/forum.php\?mod=group&amp;fid={R:2}&amp;page={R:3}&amp;{R:4}"/>
</rule>
<rulename="home_space">
<matchurl="^(.*/)*space-(username|uid)-(.+).html\?*(.*)$"/>
<actiontype="Rewrite"url="{R:1}/home.php\?mod=space&amp;{R:2}={R:3}&amp;{R:4}"/>
</rule>
<rulename="home_blog">
<matchurl="^(.*/)*blog-([0-9]+)-([0-9]+).html\?*(.*)$"/>
<actiontype="Rewrite"url="{R:1}/home.php\?mod=space&amp;uid={R:2}&amp;do=blog&amp;id={R:3}&amp;{R:4}"/>
</rule>
<rulename="forum_archiver">
<matchurl="^(.*/)*(fid|tid)-([0-9]+).html\?*(.*)$"/>
<actiontype="Rewrite"url="{R:1}/index.php\?action={R:2}&amp;value={R:3}&amp;{R:4}"/>
</rule>
</rules>
</rewrite>

ZeusWebServer

复制代码代码如下:
matchURLinto$with^(.*)/topic-(.+)\.html\?*(.*)$
ifmatchedthen
setURL=$1/portal.php?mod=topic&topic=$2&$3
endif
matchURLinto$with^(.*)/article-([0-9]+)-([0-9]+)\.html\?*(.*)$
ifmatchedthen
setURL=$1/portal.php?mod=view&aid=$2&page=$3&$4
endif
matchURLinto$with^(.*)/forum-(\w+)-([0-9]+)\.html\?*(.*)$
ifmatchedthen
setURL=$1/forum.php?mod=forumdisplay&fid=$2&page=$3&$4
endif
matchURLinto$with^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html\?*(.*)$
ifmatchedthen
setURL=$1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$5
endif
matchURLinto$with^(.*)/group-([0-9]+)-([0-9]+)\.html\?*(.*)$
ifmatchedthen
setURL=$1/forum.php?mod=group&fid=$2&page=$3&$4
endif
matchURLinto$with^(.*)/space-(username|uid)-(.+)\.html\?*(.*)$
ifmatchedthen
setURL=$1/home.php?mod=space&$2=$3&$4
endif
matchURLinto$with^(.*)/blog-([0-9]+)-([0-9]+)\.html\?*(.*)$
ifmatchedthen
setURL=$1/home.php?mod=space&uid=$2&do=blog&id=$3&$4
endif
matchURLinto$with^(.*)/(fid|tid)-([0-9]+)\.html\?*(.*)$
ifmatchedthen
setURL=$1/index.php?action=$2&value=$3&$4
endif

NginxWebServer

复制代码代码如下:
rewrite^([^\.]*)/topic-(.+)\.html$$1/portal.php?mod=topic&topic=$2last;
rewrite^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$$1/portal.php?mod=view&aid=$2&page=$3last;
rewrite^([^\.]*)/forum-(\w+)-([0-9]+)\.html$$1/forum.php?mod=forumdisplay&fid=$2&page=$3last;
rewrite^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$$1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3last;
rewrite^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$$1/forum.php?mod=group&fid=$2&page=$3last;
rewrite^([^\.]*)/space-(username|uid)-(.+)\.html$$1/home.php?mod=space&$2=$3last;
rewrite^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$$1/home.php?mod=space&uid=$2&do=blog&id=$3last;
rewrite^([^\.]*)/(fid|tid)-([0-9]+)\.html$$1/index.php?action=$2&value=$3last;
if(!-e$request_filename){
return404;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/772390.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存