Discuz教程网

Discuz 系列教程-通过判断空间类型选择伪静态方式

[复制链接]
authicon YRZhCUxn 发表于 2013-2-14 12:59:57 | 显示全部楼层 |阅读模式
本教程由crx349首发,转载请注明首发作者:crx349


程序版本:Discuz!x2.5
目的:给新手认清空间类型,从而选择合适的伪静态方式
适合人群:使用Discuz!x2.5的站长

具体内容:
1.后台,登录,首页会看到这样的一张图:
014433p3ilxmyailiooooy.png



2.仔细看这内容:

服务器系统及 PHP、服务器软件


可能的组合有:
(1)服务器系统及 PHP:WINNT / PHP v5.X.X 服务器软件:Microsoft-IIS/6.0
这时候选择的伪静态规则对应的是:IIS Web Server(独立主机用户)
  1. [ISAPI_Rewrite]
  2. # 3600 = 1 hour
  3. CacheClockRate 3600
  4. RepeatLimit 32
  5. # Protect httpd.ini and httpd.parse.errors files
  6. # from accessing through HTTP
  7. RewriteRule ^(.*)/topic-(.+).html(?(.*))*$ $1/portal.php?mod=topic&topic=$2&$4
  8. RewriteRule ^(.*)/article-([0-9]+)-([0-9]+).html(?(.*))*$ $1/portal.php?mod=view&aid=$2&page=$3&$5
  9. RewriteRule ^(.*)/forum-(w+)-([0-9]+).html(?(.*))*$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&$5
  10. RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html(?(.*))*$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3&$6
  11. RewriteRule ^(.*)/group-([0-9]+)-([0-9]+).html(?(.*))*$ $1/forum.php?mod=group&fid=$2&page=$3&$5
  12. RewriteRule ^(.*)/space-(username|uid)-(.+).html(?(.*))*$ $1/home.php?mod=space&$2=$3&$5
  13. RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+).html(?(.*))*$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&$5
  14. RewriteRule ^(.*)/(fid|tid)-([0-9]+).html(?(.*))*$ $1/index.php?action=$2&value=$3&$5
  15. RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html(?(.*))*$ $1/plugin.php?id=$2:$3&$5
复制代码
将以上内容保存为httpd.ini 上传到网站根目录
(2)服务器系统及 PHP:WINNT / PHP v5.2.16 服务器软件:Microsoft-IIS/7.X
这时候选择的伪静态规则对应的是:IIS7 Web Server(独立主机用户)
规则文件:web.zip(656 Bytes, 下载次数: 363)


备注:对应虚拟空间的用户上传这个规则就可以了,如果空间商有自定义规则方式需要和空间商客服核实下(万网是自定义规则)或者可以QQ咨询。如果是独立主机涉及到伪静态组件设置,就不在这里另外说明了。

(3)服务器系统及 PHP : Linux / PHP v5.X.X 服务器软件:Apache
这时候选择的伪静态规则对应的是:Apache Web Server(虚拟主机用户)
  1. <div id="code_Jk6"># 将 RewriteEngine 模式打开
  2. RewriteEngine On
  3. # 修改以下语句中的 /discuz 为您的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
  4. RewriteBase /
  5. # Rewrite 系统规则请勿修改
  6. RewriteCond %{QUERY_STRING} ^(.*)$
  7. RewriteRule ^topic-(.+).html$ portal.php?mod=topic&topic=$1&%1
  8. RewriteCond %{QUERY_STRING} ^(.*)$
  9. RewriteRule ^article-([0-9]+)-([0-9]+).html$ portal.php?mod=view&aid=$1&page=$2&%1
  10. RewriteCond %{QUERY_STRING} ^(.*)$
  11. RewriteRule ^forum-(w+)-([0-9]+).html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
  12. RewriteCond %{QUERY_STRING} ^(.*)$
  13. RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ forum.php?mod=viewthread&tid=$1&extra=page%3D$3&page=$2&%1
  14. RewriteCond %{QUERY_STRING} ^(.*)$
  15. RewriteRule ^group-([0-9]+)-([0-9]+).html$ forum.php?mod=group&fid=$1&page=$2&%1
  16. RewriteCond %{QUERY_STRING} ^(.*)$
  17. RewriteRule ^space-(username|uid)-(.+).html$ home.php?mod=space&$1=$2&%1
  18. RewriteCond %{QUERY_STRING} ^(.*)$
  19. RewriteRule ^blog-([0-9]+)-([0-9]+).html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
  20. RewriteCond %{QUERY_STRING} ^(.*)$
  21. RewriteRule ^archiver/(fid|
  22. 这时候会有人有疑问了:[indent][size=5][color=Red]如果是独立Linux服务器用什么规则[/color]?[/size][/indent]
  23. 如果是独立主机会有独立的httpd-vhosts.conf配置文件,可以在这个文件的网站配置字段中加入:[code]
  24. RewriteEngine On
  25. RewriteCond %{QUERY_STRING} ^(.*)$
  26. RewriteRule ^(.*)/topic-(.+).html$ $1/portal.php?mod=topic&topic=$2&%1
  27. RewriteCond %{QUERY_STRING} ^(.*)$
  28. RewriteRule ^(.*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3&%1
  29. RewriteCond %{QUERY_STRING} ^(.*)$
  30. RewriteRule ^(.*)/forum-(w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1
  31. RewriteCond %{QUERY_STRING} ^(.*)$
  32. RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3&%1
  33. RewriteCond %{QUERY_STRING} ^(.*)$
  34. RewriteRule ^(.*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3&%1
  35. RewriteCond %{QUERY_STRING} ^(.*)$
  36. RewriteRule ^(.*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3&%1
  37. RewriteCond %{QUERY_STRING} ^(.*)$
  38. RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+).html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1
  39. RewriteCond %{QUERY_STRING} ^(.*)$
  40. RewriteRule ^(.*)/(fid|tid)-([0-9]+).html$ $1/index.php?action=$2&value=$3&%1
  41. RewriteCond %{QUERY_STRING} ^(.*)$
  42. RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ $1/plugin.php?id=$2:$3&%1
复制代码
这些规则内容。
一个案例:
  1. DocumentRoot /home/xmspace
  2. ServerName [url]www.xmspace.net[/url]
  3. RewriteEngine On
  4. RewriteCond %{QUERY_STRING} ^(.*)$
  5. RewriteRule ^(.*)/topic-(.+).html$ $1/portal.php?mod=topic&topic=$2&%1
  6. RewriteCond %{QUERY_STRING} ^(.*)$
  7. RewriteRule ^(.*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3&%1
  8. RewriteCond %{QUERY_STRING} ^(.*)$
  9. RewriteRule ^(.*)/forum-(w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1
  10. RewriteCond %{QUERY_STRING} ^(.*)$
  11. RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3&%1
  12. RewriteCond %{QUERY_STRING} ^(.*)$
  13. RewriteRule ^(.*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3&%1
  14. RewriteCond %{QUERY_STRING} ^(.*)$
  15. RewriteRule ^(.*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3&%1
  16. RewriteCond %{QUERY_STRING} ^(.*)$
  17. RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+).html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1
  18. RewriteCond %{QUERY_STRING} ^(.*)$
  19. RewriteRule ^(.*)/(fid|tid)-([0-9]+).html$ $1/index.php?action=$2&value=$3&%1
  20. RewriteCond %{QUERY_STRING} ^(.*)$
  21. RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ $1/plugin.php?id=$2:$3&%1
复制代码
(4)服务器系统及 PHP : Linux / PHP v5.X.X 服务器软件:Nginx
这时候选择的伪静态规则对应的是:Nginx Web Server
如果选择的是独立服务器下面给一个案例:

vi /usr/local/nginx/conf/nginx.conf #编辑nginx配置文件
找到下面这行,在server_name localhost;后边一行添加上面的代码
  1. server {
  2. listen 80;
  3. server_name localhost;
  4. rewrite ^([^.]*)/topic-(.+).html$ $1/portal.php?mod=topic&topic=$2 last;
  5. rewrite ^([^.]*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
  6. rewrite ^([^.]*)/forum-(w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
  7. rewrite ^([^.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
  8. rewrite ^([^.]*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
  9. rewrite ^([^.]*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3 last;
  10. rewrite ^([^.]*)/blog-([0-9]+)-([0-9]+).html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
  11. rewrite ^([^.]*)/(fid|tid)-([0-9]+).html$ $1/index.php?action=$2&value=$3 last;
  12. rewrite ^([^.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ $1/plugin.php?id=$2:$3 last;
  13. if (!-e $request_filename) {
  14. return 404;
  15. }
  16. #access_log logs/host.access.log main;
  17. location / {
  18. root html;
  19. index index.php index.html index.htm;
  20. }
复制代码
如果是虚拟主机一般支持.htaccess

直接将:
  1. rewrite ^([^.]*)/topic-(.+).html$ $1/portal.php?mod=topic&topic=$2 last;
  2. rewrite ^([^.]*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
  3. rewrite ^([^.]*)/forum-(w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
  4. rewrite ^([^.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
  5. rewrite ^([^.]*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
  6. rewrite ^([^.]*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3 last;
  7. rewrite ^([^.]*)/blog-([0-9]+)-([0-9]+).html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
  8. rewrite ^([^.]*)/(fid|tid)-([0-9]+).html$ $1/index.php?action=$2&value=$3 last;
  9. rewrite ^([^.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ $1/plugin.php?id=$2:$3 last;
  10. if (!-e $request_filename) {
  11. return 404;
  12. }
复制代码
保存为.htaccess上传网站根目录,再测试是否成功,由于各家空间商的规则设置方式不同,有些使用的是自己的后台空间管理界面设置,所以在使用时还是咨询下空间商客服。[/hide]

最后一种是Zeus Web Server模式,这个由于使用相对较少,如遇到可以直接咨询空间商或QQ我

以上就是如果给新手用于判断空间类型,选择合适伪静态教程。

本教程本人独家撰写,转载请注明作者和地址,谢谢!



上一篇:x2.0 升级x3.0后 相关帖子无显示
下一篇:站点名称一直是论坛,看图
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-4 07:53

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表