Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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>
share|improve this answer
    
Thanks again, vgrem - this works perfectly. I should've figured that out myself, actually. I feel a bit ashamed now. –  BGM Jan 19 '13 at 15:33
    
:) I'm glad I could help –  Vadim Gremyachev Jan 19 '13 at 15:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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