• Sharetronix在IIS下安装及ISAPI_Rewrite的httpd.ini规则

    首先我们得承认:Sharetronix安装程序会检测是不是Apache服务器,以及有没有mod_rewrite模块。如果是IIS而不是Apache,则会终止安装。这时候,我们可以修改安装文件的检测步骤来跳过这个检测。

    但有更简单的方法,就是在本地Apache环境下安装好Sharetronix,再上传安装好的目录及数据库。别忘了要更改配置文件conf_main.php来适应主机上的设置哦。

    怎么rewrite呢?这里以ISAPI_Rewrite的httpd.ini为例。IIS7已经可以转换.htaccess为web.config了,就不用这么麻烦。

    httpd.ini代码,假设程序安装在“sharetronix”目录下:

    [ISAPI_Rewrite]

    # 3600 = 1 hour
    CacheClockRate 3600

    RepeatLimit 32

    RewriteCond URL /sharetronix(?!/api/|/i/|/system/|/themes/|/uc_client/).*
    RewriteRule /sharetronix(.*) /sharetronix/_chineseuri.php?$1 [I]

    httpd.ini上传至相应文件夹,每个主机商都会不一样,这个自己要注意。

    然后把一下内容保存为“_chineseuri.php”,以“UTF-8 无BOM”格式保存。上传至sharetronix的安装目录。

    <?php
    
    // IIS Mod-Rewrite
    if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
    }
    // IIS Isapi_Rewrite
    else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    }
    else
    {
    // Use ORIG_PATH_INFO if there is no PATH_INFO
    if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
    $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
    
    // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
    if ( isset($_SERVER['PATH_INFO']) ) {
    if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
    $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
    else
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
    }
    
    // Append the query string if it exists and isn't null
    if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
    $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
    }
    }
    
    require("index.php");
    
    ?> 

    OK!Sharetronix在IIS下完美运作!

    下次将向大家介绍一些Sharetronix联合QQ机器人。现在我已经装了个预览版,可以在这里围观:http://t.lufie.net/sharetronix/