URL Rewriting and Anonymous Access with SharePoint – Part Four

23 Mar

Outgoing Rules

Our URL’s look good now when we are coming into the site, but what about navigating around the site? We could rewrite the SharePoint links to the pretty URL’s by accepting the full URL and changing it after it is clicked e.g. http://geeksinsuits.com/CA/Pages/Default.aspx will be clicked and then rewritten into http://geeksinsuits.com/CA/Default (this was an optional step earlier). But this means our users can see URL’s that are inconsistent with the actual URL we are using. To get around this we will make an outgoing rule that will rewrite the links on the page.

  1. Go to the public sites URL Rewrite rules
  2. Create the outbound rule to rewrite page URL’s
    1. Click on Add Rule, select Blank rule under Outbound rules
    2. Give the rule a name of “Rewrite html Urls into readable Urls” or something similar
    3. Create a Precondition. Give it the Name “IsHTML”, leave Using as Regular Expressions. Add a condition With the Condition Input set to {RESPONSE_CONTENT_TYPE}. Leave the input string as Matches the Pattern. Set the Pattern to ^text/html
    4. Make the matching scope Response
    5. Set Match the content within as A, Link and Area. This should cover most of our URL scenarios
    6. Set the Pattern to ^(.*)/?/Pages/(.*)/?\.aspx(.*)/?$
    7. Ignorethe case
    8. Set the Action to Rewrite
    9. Add the Value {R:1}/{R:2}{R:3}
    10. Tick Stop processing of subsequent rules
  3. Go to the main page. You will either not see anything or you will get a 500 error. The reason for this is that Dynamic Compression is turned on and the outbound rewriting only works with un compressed responses.
  4. Turn Dynamic Compression off
    1. Go to the public facing site and double click on Compression
    2. Untick Enable dynamic content compression
  5. Now refresh the page, everything should show up fine. If performance is going to be a problem read this post for a work around
  6. To test that this has worked hover over the URL for California on the left. It now looks like the URL in the browser

For more information on Outbound rules click here.

Kool, anything else I need to think about? Next Post… (URL Rewriting with Search and XSLT)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: