IIS 7.5 URL.config中的重写规则不起作用

时间:2012-08-08 15:23:48

标签: url-rewriting windows-server-2008 iis-7.5

我刚将另一个站点移动到服务器但URL重写规则不起作用。所以,我从iis.net安装了URL Rewrite 2.0,但没有运气。

当我从IIS管理器中选择网站但没有记录时,我可以看到URL Rewrite图标。

我不想将规则从web.config逐个移到URL Rewrite部分。

这里是web.config文件的内容;

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <configSections>
        ...
        <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" requirePermission="false" />
    </configSections>

    <RewriterConfig>
        <Rules>
            <!-- TR -->
            <RewriterRule>
                <LookFor>~/Sayfalar/Kategoriler/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ParentRawUrl=$2&amp;RawUrl=$3&amp;ID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Sayfalar/Kategoriler/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?RawUrl=$2&amp;ID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Sayfalar/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?ParentRawUrl=$2&amp;RawUrl=$3&amp;ID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Sayfalar/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Kategoriler/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ID=2&amp;CategoryID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Urunler/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ID=2&amp;ProductID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Haberler/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=30&amp;NewsID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Tarifler/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=22&amp;RecipeID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Sizin-Tarifiniz/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=21&amp;YourRecipeID=$1&amp;Lang=0</SendTo>
            </RewriterRule>
            <!-- // TR -->
            <!-- AR -->
            <RewriterRule>
                <LookFor>~/Arabic.aspx</LookFor>
                <SendTo>~/Default.aspx?Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Sfhat/Al-Fiat/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ParentRawUrl=$2&amp;RawUrl=$3&amp;ID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Sfhat/Al-Fiat/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?RawUrl=$2&amp;ID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Sfhat/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?ParentRawUrl=$2&amp;RawUrl=$3&amp;ID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Sfhat/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Al-Fiat/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ID=59&amp;CategoryID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Al-Mntjat/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ID=59&amp;ProductID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Khbar/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=58&amp;NewsID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Wsfat/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=63&amp;RecipeID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Ldyk-Wşfh/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=62&amp;YourRecipeID=$1&amp;Lang=1</SendTo>
            </RewriterRule>
            <!-- // AR -->
            <!-- // ENG -->
            <RewriterRule>
                <LookFor>~/English.aspx</LookFor>
                <SendTo>~/Default.aspx?Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Pages/Categories/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ParentRawUrl=$2&amp;RawUrl=$3&amp;ID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Pages/Categories/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?RawUrl=$2&amp;ID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Pages/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?ParentRawUrl=$2&amp;RawUrl=$3&amp;ID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Pages/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Categories/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ID=111&amp;CategoryID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Product/(.*)/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Product.aspx?ID=111&amp;ProductID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/News/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=30&amp;NewsID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Recipes/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=118&amp;RecipeID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/Your-Recipes/(.*)/(.*).aspx</LookFor>
                <SendTo>~/Page.aspx?RawUrl=$2&amp;ID=119&amp;YourRecipeID=$1&amp;Lang=2</SendTo>
            </RewriterRule>
            <!-- // ENG -->
        </Rules>
    </RewriterConfig>
    <system.web>
        ...
    </system.web>
    ...
    <system.webServer>
        ...
    </system.webServer>
    ...
</configuration>

我该怎么办?

1 个答案:

答案 0 :(得分:2)

这些规则不适用于Microsoft URL重写模块。通过谷歌搜索RewriterConfig我发现这些规则可能适用于Spring MVC重写模块。