0

On this page I found out how to remap username links to custom pages.

However, I on certain pages I need to remap to an administrator's user info page. How can I modify the url rewrite rule to accomodate this?

I have two rules here - one for regular users and one for admin, which is based on which page is being used as the source. So, I want the admin links for just certain pages, and any other page should go to the user page instead.

But using what I have here breaks the entire site.

Here is the rule:

    <rule name="Admin Info Link" enabled="true" stopProcessing="true">
        <match url="^(.*/)?_layouts/userdisp.aspx$" />
        <action type="Redirect" url="/SitePages/user.aspx?userID={C:1}" appendQueryString="false" />
        <conditions trackAllCaptures="true">
            <add input="{HTTP_HOST}{REQUEST_URI}" pattern="*/whatsite/whatpage*" />
                            <add input="{QUERY_STRING}" pattern="ID=(\d+)" />
        </conditions>
    </rule>        
    <rule name="User Info Link" enabled="true" stopProcessing="true">
        <match url="^(.*/)?_layouts/userdisp.aspx$" />
        <action type="Redirect" url="/SitePages/user.aspx?userID={C:1}" appendQueryString="false" />
        <conditions trackAllCaptures="true">
            <add input="{QUERY_STRING}" pattern="ID=(\d+)" />
        </conditions>
    </rule> 

How do I do this correctly?

1

It could be accomplished by specifying more narrow match pattern for url

For example, let's discuss the scenario, where requests from:

http://{ServerName}/_layouts/teamsiteA/userdisp.aspx?ID=1

should be redirected to:

http://{ServerName}/SitePages/UserInfoA.aspx?userID=1

and requests from:

http://{ServerName}/_layouts/teamsiteB/userdisp.aspx?ID=1

should be redirected to:

http://{ServerName}/SitePages/UserInfoB.aspx?userID=1

XML Rules declaration for that case may look like this:

                <rule name="Team Site A User Info Link" stopProcessing="true">
                    <match url="^(.*/)?teamsiteA/_layouts/userdisp.aspx$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                        <add input="{QUERY_STRING}" pattern="ID=(\d+)" />
                    </conditions>
                    <action type="Redirect" url="/SitePages/UserInfoA.aspx?userID={C:1}" appendQueryString="false" />
                </rule>
                <rule name="Team Site B User Info Link" enabled="true" stopProcessing="true">
                    <match url="^(.*/)?teamsiteB/_layouts/userdisp.aspx$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                        <add input="{QUERY_STRING}" pattern="ID=(\d+)" />
                    </conditions>
                    <action type="Redirect" url="/SitePages/UserInfoB.aspx?userID={C:1}" appendQueryString="false" />
                </rule>
  • Thanks again, vgrem - this works perfectly. I should've figured that out myself, actually. I feel a bit ashamed now. – bgmCoder Jan 19 '13 at 15:33
  • :) I'm glad I could help – Vadim Gremyachev Jan 19 '13 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.