Apache
在Apache下,利用mod_rewrite来实现URL的静态化。

编写一个.htaccess的内容如下:
# BEGIN WordPress

RewriteEngine On 
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

上传到主机空间即可

我搞了好几个discuz网站,伪静态一直没搞定,这次研究了好久总算搞定了,特来分享经验。(本文基于军哥的lnmp.org一键安装包配置lnmp环境)

第一步:修改conf文件,找到站点.conf文件,LNMP在/usr/local/nginx/conf/vhost下

 

第二步,替换include discuz.conf;为一下代码

rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
if (!-e $request_filename) {
return 404;
}
第三步重启nginx,登陆SSH使用如下命令:/root/lnmp restart
至此,大功告成