深情的呼唤

深情的呼唤 首 页 其它 查看内容

dama

2018-12-1 21:01| 发布者: 永兴| 查看: 629| 评论: 0

[Discuz!] Discuz! X3.0/X3.1/X3.2通用 Apache伪静态规则

1.在后台“全局》SEO设置》URL 静态化”相关复选框全部勾选,点“提交”按钮。

2.下载附件.htaccess直接用FTP上传论坛根目录即可,不要修改文件名,就是.htaccess
其他目录的话修改第2行“RewriteBase /discuz” 把discuz换成目录名,如在bbs目录则改为:RewriteBase /bbs  .htaccess文件放在bbs目录

默认规则如下:
  1. RewriteEngine On
  2. RewriteBase /discuz

  3. RewriteCond %{QUERY_STRING} ^(.*)$
  4. RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
  5. RewriteCond %{QUERY_STRING} ^(.*)$
  6. RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
  7. RewriteCond %{QUERY_STRING} ^(.*)$
  8. RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
  9. RewriteCond %{QUERY_STRING} ^(.*)$
  10. RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
  11. RewriteCond %{QUERY_STRING} ^(.*)$
  12. RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
  13. RewriteCond %{QUERY_STRING} ^(.*)$
  14. RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
  15. RewriteCond %{QUERY_STRING} ^(.*)$
  16. RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
  17. RewriteCond %{QUERY_STRING} ^(.*)$
  18. RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
  19. RewriteCond %{QUERY_STRING} ^(.*)$
  20. RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1
复制代码

.htaccess (1.24 KB)

X3.0伪静态规则

Discuz! X2.5 Apache伪静态规则

默认规则如下:
  1. RewriteEngine On
  2. RewriteBase /discuz
  3. # Rewrite 系统规则请勿修改
  4. RewriteCond %{QUERY_STRING} ^(.*)$
  5. RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
  6. RewriteCond %{QUERY_STRING} ^(.*)$
  7. RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
  8. RewriteCond %{QUERY_STRING} ^(.*)$
  9. RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
  10. RewriteCond %{QUERY_STRING} ^(.*)$
  11. RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
  12. RewriteCond %{QUERY_STRING} ^(.*)$
  13. RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
  14. RewriteCond %{QUERY_STRING} ^(.*)$
  15. RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
  16. RewriteCond %{QUERY_STRING} ^(.*)$
  17. RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
  18. RewriteCond %{QUERY_STRING} ^(.*)$
  19. RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
  20. RewriteCond %{QUERY_STRING} ^(.*)$
  21. RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1
复制代码

TOP

Discuz! X2.0 Apache伪静态规则

默认规则如下:
  1. # 将 RewriteEngine 模式打开
  2. RewriteEngine On

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

  5. # Rewrite 系统规则请勿修改
  6. RewriteCond %{QUERY_STRING} ^(.*)$
  7. RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$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
复制代码
Discuz! X2 相对于 X15 来说,rewrite 做了一定的调整:
1. 后台位置变化:由 X15 的“全局 → 优化设置”,调整为 X2 的“全局 → SEO设置”
2. 数量变化:由 X15 的 6 项针对性设置 + 1 项全站动态页面,调整为 X2 的 8 项针对设置性

如果希望对之前的已经收录的rewrite仍可以访问,可以做如下兼容:

1. 修改 rewrite 规则:有两种方法可以使用
1) 将 X2 后台提供的 rewrtie 规则放在 X15 的规则的前面即可,任何规则都可以不删除
2) 将下面地址中的 rewrite 规则放在 X15 的规则的前面
http://www.discuz.net/thread-2109624-1-1.html
2. 修改文件:
找到:source/class/class_core.php 191行附近

  1. function _init_input() {
  2. if (isset($_GET['GLOBALS']) ||isset($_POST['GLOBALS']) || isset($_COOKIE['GLOBALS']) || isset($_FILES['GLOBALS'])) {
  3. system_error('request_tainting');
  4. }
  5. if(!MAGIC_QUOTES_GPC) {
  6. $_GET = daddslashes($_GET);
  7. $_POST = daddslashes($_POST);
  8. $_COOKIE = daddslashes($_COOKIE);
  9. $_FILES = daddslashes($_FILES);
  10. }
复制代码
修改为

  1. function _init_input() {
  2. if (isset($_GET['GLOBALS']) ||isset($_POST['GLOBALS']) || isset($_COOKIE['GLOBALS']) || isset($_FILES['GLOBALS'])) {
  3. system_error('request_tainting');
  4. }
  5. if(!empty($_GET['rewrite'])) {
  6. $query_string = '?mod=';
  7. $param = explode('-', $_GET['rewrite']);
  8. $query_string .= $_GET['mod'] = $param[0];
  9. array_shift($param);
  10. $paramc = count($param);
  11. for($i = 0;$i < $paramc;$i+=2) {
  12. $_REQUEST[$param[$i]] = $_GET[$param[$i]] = $param[$i + 1];
  13. $query_string .= '&'.$param[$i].'='.$param[$i + 1];
  14. }
  15. $_SERVER['QUERY_STRING'] = $query_string;
  16. unset($param, $paramc, $query_string);
  17. }
  18. if(!MAGIC_QUOTES_GPC) {
  19. $_GET = daddslashes($_GET);
  20. $_POST = daddslashes($_POST);
  21. $_COOKIE = daddslashes($_COOKIE);
  22. $_FILES = daddslashes($_FILES);
  23. }
复制代码

最新评论

QQ|关于我们|京公网安备11011102001446号|京ICP备15066982号-1 ( 深情的呼唤  

GMT+8, 2021-4-22 22:03 , Processed in 0.041635 second(s), 17 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

返回顶部