建站知识
当前位置 :主页 > 建站知识 >

discuz x3.0iis和linux伪静态设置方法

来源:互联网 时间:2014-05-21
 新手站长在用Discuz程序搭建网站后,会发现自己的网站地址是动态地址,所谓动态地址就是带有?号这种,比如http://域名/forum.php?mod=···这种就属于动态地址,那么,我们想要网站就行伪静态,也就是以html结尾的网址,该如何做呢?wbchz在这里教一下新手站长:

方法/步骤

  1. 进入后台,找到“全局”——“SEO设置”,如图,把右边“可用”下方的框全给勾选

    详解如何设置Discuz论坛伪静态
  2. 此时你到网站首页,刷新一下,你会看到你的网站地址全变成了伪静态,也就是html结尾的文章或者栏目地址,但是你点进去,会发现出现无法打开页面,是因为你设置了伪静态,却没做伪静态处理,不同的主机,使用不同的伪静态规则才能使之实现伪静态。如果你的是Apache主机,请把下面代码复制到记事本,保存为.htaccess并上传到空间根目录即可

    # Helicon ISAPI_Rewrite configuration file

    # Version 3.1.0.82

     

    # 将 RewriteEngine 模式打开

    RewriteEngine On

     

    # 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /

    RewriteBase /

     

    # 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

  3. 如果你是IIS主机,复制下面代码到记事本,保存为http.ini然后上传到空间根目录即可

    [ISAPI_Rewrite]

     

    # 3600 = 1 hour

    CacheClockRate 3600

     

    RepeatLimit 32

     

    # Protect httpd.ini and httpd.parse.errors files

    # from accessing through HTTP

    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