xmao’s blog

Tag: iis7

Discuz 在IIS7下的Rewrite规则

by xmao on Mar.06, 2009, under Development, Internet, System, Windows Server

Discuz使用IIS7的Rewrite模块,与官方使用第三方的规则还是略有区别,给个简单例子,你可以举一反三..
加入到web.config中的..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        <rewrite>
            <rules>
                <rule name="Forumdisplay Rewrite Rule" stopProcessing="true">
                    <match url="^forum-([^/]+)-([^/]+).html?$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="forumdisplay.php?fid={R:1}&amp;page={R:2}" />
                </rule>
                <rule name="Viewthread Rewrite Rule" stopProcessing="true">
                    <match url="^thread-([^/]+)-([^/]+)-([^/]+).html?$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="viewthread.php?tid={R:1}&amp;extra=page%3D{R:2}&amp;page={R:3}" />
                </rule>
            </rules>
        </rewrite>
Leave a Comment :, , more...

wordpress2.71在iis7下rewrite完美解决

by xmao on Feb.17, 2009, under Internet, Wordpress

解决中文路径问题

wordpress设定Permalink后一个最大的问题是中文不正常,主要原因是IIS解释路径是GBK编码,转给wordpress按UTF-8取值就不对了。

解决办法

打开wp-includes\classes.php文件,找到

1
2
3
4
5
6
7
if ( isset($_SERVER['PATH_INFO']) )
        $pathinfo = $_SERVER['PATH_INFO'];
else
        $pathinfo = '';
        $pathinfo_array = explode('?', $pathinfo);
        $pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
        $req_uri = $_SERVER['REQUEST_URI'];

替换为:

1
2
3
4
5
6
7
if ( isset($_SERVER['PATH_INFO']) )
        $pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK");
else
        $pathinfo = '';
        $pathinfo_array = explode('?', $pathinfo);
        $pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
        $req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK");

index.php模式

wordpress通过index.php实现的友好路径已经很不错了,你在Permalink Settings直接设置就行了..这个模式在IIS7下面很正常

如果你实在是一个完美主义者请继续往下

IIS7 rewrite组件模式

下载组件和相关说明参见:

Microsoft URL Rewrite Module for IIS 7.0 (x86)

Using URL Rewrite Module

如果您时间有限,请看以下简单安装

1 下载安装..这个必须的,安装完,你会看到IIS管理器中多了个URL Rewrite功能,但我们不用管它。

2 打开wordpress目录中的web.config,在system.webServer element中添加

1
2
3
4
5
6
7
8
9
10
11
12
<rewrite>
    <rules>
        <rule name="Main Rule" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php" />
        </rule>
    </rules>
</rewrite>

3 然后你就可以在Permalink Settings去掉看不顺眼的index.php了 :)

2 Comments :, , , more...

win2008&IIS7环境下FastCGI模式PHP安装

by xmao on Feb.17, 2009, under System, Windows Server

网上有很多文章不够正确,其实iis.net上说的很详细了:

Using FastCGI to Host PHP Applications on IIS 7.0

如果你害怕看英文字母,那就跟着我简单安装吧 :)

安装FastCGI功能

1 打开服务器管理器,添加CGI,你可以自己的需求安装其他胡功能,如果只想跑PHP,只选CGI就行了

安装CGI功能

配置PHP

1 下载PHP解压缩免安装版,我选择的是最新的php5.28

2 加压到某个目录,全路径中不要有空格,配置时会有点麻烦,我直接 c:\php

3 复制php.ini-dict改名为php.ini,注意以下设置

fastcgi.impersonate = 1
cgi.fix_pathinfo=1
cgi.force_redirect
= 0
extension_dir = “./ext”

extension=php_mysql.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_zip.dll
extension=php_mcrypt.dll

这样跑一般的PHP程都行了。

配置IIS支持PHP

1 打开信息服务管理器,选中服务器,打开处理程序映射,添加模块映射

安装应用程序映射

2 系统会提示你,添加 isapi/cgi限制,你可以再去看看,有下面的设置就没有问题了

iis7php03

这样就OK了,你可以按照自己的需求,设置一下缓存。

缓存

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...