phpstudy安裝選擇,iis+php組合,如何設定偽靜態

冰點沐雪發表於2016-05-12

如題。

找了半天,終於找到解決方案了。

需要在伺服器上安裝 Url rewrite 元件。

伺服器是64位則安裝: rewrite_2.0_rtw_x64.exe

 然後新增 web.config配置檔案,放到站點的根目錄。

檔案內容如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
           <add value="portal.php" />
                <add value="Default.htm" />
                <add value="index.htm" />
                <add value="Default.asp" />
                <add value="index.html" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />
            </files>
        </defaultDocument>
<rewrite>
    <rules>
        <rule name="portal_topic">
            <match url="^(.*/)*topic-(.+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/portal.php?mod=topic&amp;topic={R:2}&amp;{R:3}" />
        </rule>
        <rule name="portal_article">
            <match url="^(.*/)*article-([0-9]+)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/portal.php?mod=view&amp;aid={R:2}&amp;page={R:3}&amp;{R:4}" />
        </rule>
        <rule name="forum_forumdisplay">
            <match url="^(.*/)*forum-(w+)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/forum.php?mod=forumdisplay&amp;fid={R:2}&amp;page={R:3}&amp;{R:4}" />
        </rule>
        <rule name="forum_viewthread">
            <match url="^(.*/)*thread-([0-9]+)-([0-9]+)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/forum.php?mod=viewthread&amp;tid={R:2}&amp;extra=page%3D{R:4}&amp;page={R:3}&amp;{R:5}" />
        </rule>
        <rule name="group_group">
            <match url="^(.*/)*group-([0-9]+)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/forum.php?mod=group&amp;fid={R:2}&amp;page={R:3}&amp;{R:4}" />
        </rule>
        <rule name="home_space">
            <match url="^(.*/)*space-(username|uid)-(.+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/home.php?mod=space&amp;{R:2}={R:3}&amp;{R:4}" />
        </rule>
        <rule name="home_blog">
            <match url="^(.*/)*blog-([0-9]+)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/home.php?mod=space&amp;uid={R:2}&amp;do=blog&amp;id={R:3}&amp;{R:4}" />
        </rule>
        <rule name="forum_archiver">
            <match url="^(.*/)*(fid|tid)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/index.php?action={R:2}&amp;value={R:3}&amp;{R:4}" />
        </rule>
        <rule name="plugin">
            <match url="^(.*/)*([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/plugin.php?id={R:2}:{R:3}&amp;{R:4}" />
        </rule>

<rule name="help_list">
            <match url="^(.*/)*list-(w+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/plugin.php?id=wq_help&amp;cid={R:2}&amp;{R:3}" />
        </rule>
        <rule name="article_list">
            <match url="^(.*/)*articlelist-([0-9]+)-([0-9]+)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/plugin.php?id=wq_wechatcollecting&amp;mod=list&amp;classid={R:2}&amp;displayorder={R:3}&amp;page={R:4}&amp;{R:5}" />
        </rule>
        <rule name="article_view">
            <match url="^(.*/)*wechatarticle-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/plugin.php?id=wq_wechatcollecting&amp;mod=view&amp;articleid={R:2}&amp;{R:3}" />
        </rule>
        <rule name="wechat_list">
            <match url="^(.*/)*wechatlist-([0-9]+)-([0-9]+)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/plugin.php?id=wq_wechatshow&amp;mod=list&amp;classid={R:2}&amp;displayorder={R:3}&amp;page={R:4}&amp;{R:5}" />
        </rule>
        <rule name="wechat_view">
            <match url="^(.*/)*wechat-(w+)-([0-9]+).html?*(.*)$" />
            <action type="Rewrite" url="{R:1}/plugin.php?id=wq_wechatshow&amp;mod=view&amp;wid={R:2}&amp;page={R:3}&amp;{R:4}" />
        </rule>

    </rules>
</rewrite>
    </system.webServer>
</configuration>

View Code

我用的是discuz的一套偽靜態規則。


相關文章