代码之家  ›  专栏  ›  技术社区  ›  Duong Van

正在将.htaccess转换为IIS web.config

  •  0
  • Duong Van  · 技术社区  · 6 年前

    所有请求都有500个错误 .

    下面是我的htaccess重写配置:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_URI} !(/$|\.) 
    RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 
    
    RewriteRule ^(en)/rooms/([a-zA-Z0-9-_]+)/?$ index.php?lang=$1&page=room&room_id=$2 [L,QSA]
    RewriteRule ^(en)/([a-zA-Z0-9-_]+)/?$ index.php?lang=$1&page=$2 [L,QSA]
    RewriteRule ^(en)/?$ index.php?lang=$1 [L,QSA]
    
    RewriteRule ^rooms/([a-zA-Z0-9-_]+)/?$ index.php?page=room&room_id=$1 [L,QSA]
    RewriteRule ^([a-zA-Z0-9-_]+)/?$ index.php?page=$1 [L,QSA]
    </IfModule>
    

    我试图通过使用 online tool here 并收到以下结果:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="rule 1Q" stopProcessing="true">
                        <match url="!(/$|\.)"  />
                        <action type="Rewrite" url="%{REQUEST_URI}/"  />
                    </rule>
                    <rule name="rule 2a" stopProcessing="true">
                        <match url="^(en)/rooms/([a-zA-Z0-9-_]+)/?$"  />
                        <action type="Rewrite" url="/index.php?lang={R:1}&page=room&room_id={R:2}"  appendQueryString="true" />
                    </rule>
                    <rule name="rule 3a" stopProcessing="true">
                        <match url="^(en)/([a-zA-Z0-9-_]+)/?$"  />
                        <action type="Rewrite" url="/index.php?lang={R:1}&page={R:2}"  appendQueryString="true" />
                    </rule>
                    <rule name="rule 4a" stopProcessing="true">
                        <match url="^(en)/?$"  />
                        <action type="Rewrite" url="/index.php?lang={R:1}"  appendQueryString="true" />
                    </rule>
                    <rule name="rule 5a" stopProcessing="true">
                        <match url="^rooms/([a-zA-Z0-9-_]+)/?$"  />
                        <action type="Rewrite" url="/index.php?page=room&room_id={R:1}"  appendQueryString="true" />
                    </rule>
                    <rule name="rule 6a" stopProcessing="true">
                        <match url="^([a-zA-Z0-9-_]+)/?$"  />
                        <action type="Rewrite" url="/index.php?page={R:1}"  appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
            <httpErrors>
                ...
            </httpErrors>
        </system.webServer>
    </configuration>
    

    这是我第一次在I is和Plesk上工作,所以我对这个问题一无所知。所以请让我知道如何解决这个问题。如有任何帮助,我们将不胜感激。谢谢

    0 回复  |  直到 6 年前