• 返回列表

    [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. }
    復制代碼

    TOP

    返回列表
    新婚少妇莹莹系列