设为首页收藏本站

IITT网络服务中心

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2663|回复: 0
打印 上一主题 下一主题

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

[复制链接]

453

主题

399

帖子

1764

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1764
跳转到指定楼层
楼主
发表于 2018-2-28 03:02:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
程序版本:Discuz!x1.5-x3.1
目的:给新手认清空间类型,从而选择合适的伪静态方式
适合人群:使用Discuz!x1.5-x3.1的站长

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

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, 下载次数: 0)



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

(3)服务器系统及 PHP : Linux / PHP v5.X.X  服务器软件:Apache
这时候选择的伪静态规则对应的是:Apache Web Server(虚拟主机用户)
  1. # 将 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|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
  22. RewriteCond %{QUERY_STRING} ^(.*)$
  23. RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1
复制代码

以上规则具体如何使用见http://service.iitt.cc/thread-4804-1-1.html

这时候会有人有疑问了:
如果是独立Linux服务器用什么规则


如果是独立主机会有独立的httpd-vhosts.conf配置文件,可以在这个文件的网站配置字段中加入:
  1. <IfModule mod_rewrite.c>
  2.         RewriteEngine On
  3.         RewriteCond %{QUERY_STRING} ^(.*)$
  4.         RewriteRule ^(.*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2&%1
  5.         RewriteCond %{QUERY_STRING} ^(.*)$
  6.         RewriteRule ^(.*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3&%1
  7.         RewriteCond %{QUERY_STRING} ^(.*)$
  8.         RewriteRule ^(.*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1
  9.         RewriteCond %{QUERY_STRING} ^(.*)$
  10.         RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&%1
  11.         RewriteCond %{QUERY_STRING} ^(.*)$
  12.         RewriteRule ^(.*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3&%1
  13.         RewriteCond %{QUERY_STRING} ^(.*)$
  14.         RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3&%1
  15.         RewriteCond %{QUERY_STRING} ^(.*)$
  16.         RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1
  17.         RewriteCond %{QUERY_STRING} ^(.*)$
  18.         RewriteRule ^(.*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3&%1
  19.         RewriteCond %{QUERY_STRING} ^(.*)$
  20.         RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3&%1
  21. </IfModule>
复制代码

这些规则内容。
一个案例:
  1. <VirtualHost *:80>
  2. DocumentRoot /home/xmspace
  3. ServerName [url]www.xmspace.net[/url]
  4. <IfModule mod_rewrite.c>
  5.         RewriteEngine On
  6.         RewriteCond %{QUERY_STRING} ^(.*)$
  7.         RewriteRule ^(.*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2&%1
  8.         RewriteCond %{QUERY_STRING} ^(.*)$
  9.         RewriteRule ^(.*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3&%1
  10.         RewriteCond %{QUERY_STRING} ^(.*)$
  11.         RewriteRule ^(.*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1
  12.         RewriteCond %{QUERY_STRING} ^(.*)$
  13.         RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&%1
  14.         RewriteCond %{QUERY_STRING} ^(.*)$
  15.         RewriteRule ^(.*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3&%1
  16.         RewriteCond %{QUERY_STRING} ^(.*)$
  17.         RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3&%1
  18.         RewriteCond %{QUERY_STRING} ^(.*)$
  19.         RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1
  20.         RewriteCond %{QUERY_STRING} ^(.*)$
  21.         RewriteRule ^(.*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3&%1
  22.         RewriteCond %{QUERY_STRING} ^(.*)$
  23.         RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3&%1
  24. </IfModule>
  25. </VirtualHost>
复制代码

(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上传网站根目录,再测试是否成功,由于各家空间商的规则设置方式不同,有些使用的是自己的后台空间管理界面设置,所以在使用时还是咨询下空间商客服。

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

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

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|IITT网络服务中心    

GMT+8, 2024-4-29 11:02 , Processed in 0.081439 second(s), 27 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

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