.htaccess Modx Evolution重写URL Web.Config IIS

.htaccess Modx Evolution重写URL Web.Config IIS,.htaccess,iis,web-config,modx,modx-evolution,.htaccess,Iis,Web Config,Modx,Modx Evolution,我需要帮助将htaccess转换为IIS服务器的web.config。 Modx Evolution 1.x使用此htaccess #php_flag register_globals Off #AddDefaultCharset utf-8 #php_value date.timezone Europe/Moscow Options +FollowSymlinks RewriteEngine on RewriteBase / # Fix Apache internal dummy conn

我需要帮助将htaccess转换为IIS服务器的web.config。
Modx Evolution 1.x使用此htaccess

#php_flag register_globals Off
#AddDefaultCharset utf-8
#php_value date.timezone Europe/Moscow

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

# Fix Apache internal dummy connections from breaking [(site_url)] cache
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]

# Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
#RewriteRule (.*) http://www.example.com/$1 [R=301,L]

# Exclude /assets and /manager directories and images from rewrite rules
RewriteRule ^(manager|assets)/*$ - [L]
RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]

# For Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

我需要将此配置转换为IIS服务器的web.config。

将其作为web.config放在web服务器的根文件夹中,将example.com更改为您的域名:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="Default.aspx" />
            </files>     
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="Add WWW prefix" >
                  <match url="(.*)" ignoreCase="true" />
                    <conditions>
                      <add input="{HTTP_HOST}" pattern="^example\.com" />
                    </conditions>
                  <action type="Redirect" url="http://www.example.com/{R:1}"
                    redirectType="Permanent" />
                </rule> 

                <rule name="ModX IIS7 Rule 1" stopProcessing="true">
                    <match url=".*" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTP_USER_AGENT}" pattern="^.*internal\ dummy\ connection.*$" />
                    </conditions>
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="ModX IIS7 Rule 2" stopProcessing="true">
                    <match url="^(manager|assets)" ignoreCase="false" />
                    <action type="None" />
                </rule>              
                <rule name="ModX IIS7 Rule 3" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" />
                    </conditions>
                    <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>          
    </system.webServer>
</configuration>

将其作为web.config放在web服务器的根文件夹中,将example.com更改为您的域名:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="Default.aspx" />
            </files>     
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="Add WWW prefix" >
                  <match url="(.*)" ignoreCase="true" />
                    <conditions>
                      <add input="{HTTP_HOST}" pattern="^example\.com" />
                    </conditions>
                  <action type="Redirect" url="http://www.example.com/{R:1}"
                    redirectType="Permanent" />
                </rule> 

                <rule name="ModX IIS7 Rule 1" stopProcessing="true">
                    <match url=".*" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTP_USER_AGENT}" pattern="^.*internal\ dummy\ connection.*$" />
                    </conditions>
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="ModX IIS7 Rule 2" stopProcessing="true">
                    <match url="^(manager|assets)" ignoreCase="false" />
                    <action type="None" />
                </rule>              
                <rule name="ModX IIS7 Rule 3" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" />
                    </conditions>
                    <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>          
    </system.webServer>
</configuration>