views:

16

answers:

1

Hello, I have a problem:

I have an URL like that :

/eng/myfolder/mycategory.aspx

I would like to transform it in something like:

index.aspx?FolderId=2&LanguageId=1&CategoryID=12

In a word I want to "write" that,

eng => languageId=2 and myfolder => FolderId=2 and mycategory.....

I don't know if i make myself clear but

Thanks.

with http://mywebsite.com/fr/default

Right Now i have :

 <add key = "/en/default"  value = "default.aspx?LanguageId=1" />

 <add input = " {Rewrite:{REQUEST_URI}}" pattern = "default.aspx\?(.+)" />

 <action type="rewrite" url="default.aspx?{C:1}" appendQueryString="False" /> 

But i want Something more global like:

 <add key = "/en"  value = "LanguageId=1" /> 

 <add input = " {Rewrite:{REQUEST_URI}}" pattern = "(.+)" /> 

  < action type="rewrite" url="default.aspx?{C:1}" appendQueryString="False" />
A: 

This is how I would do it, basically create three maps, one for languages, folders and cateogories. If they have large data sets and possibly changing frequently then I would consider using custom provider built in C#, but for now just:

<configuration>
    <system.webServer>
        <rewrite>
            <rewriteMaps>
                <rewriteMap name="Folders">
                    <add key="myfolder" value="2" />
                    <add key="anotherfolder" value="3" />
                </rewriteMap>
                <rewriteMap name="Languages">
                    <add key="eng" value="2" />
                    <add key="spa" value="1" />
                </rewriteMap>
                <rewriteMap name="Categories">
                    <add key="mycategory" value="12" />
                    <add key="anothercategory" value="10" />
                </rewriteMap>
            </rewriteMaps>
            <rules>
                <rule name="RewriteURLs" stopProcessing="true">
                    <match url="([^/]+)/([^/]+)/(.+?)\.aspx" />
                    <action type="Rewrite" url="/index.aspx?FolderId={Folders:{R:2}}&amp;languageid={Languages:{R:1}}&amp;CategoryID={Categories:{R:3}}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
CarlosAg
Thanks you very much!!That was exactly what i was looking for
grogoin