community-server+redirect Questions - SnippetGoodmost recent 30 from http://snippetgood.com2010-09-07T04:36:43Zhttp://snippetgood.com/feeds/tag/community-server%2bredirecthttp://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://snippetgood.com/questions/44/community-server-redirection-with-siteurls-configCommunity Server Redirection with SiteUrls.configbinky2009-10-06T15:42:01Z2009-10-06T18:07:53Z
<p>It took me forever to figure out how to do this in CS 4, so I wanted to document what I did and see if anyone had any other suggestions to make this better:</p>
<p>The page is called stunt.aspx and it's physical location is <code>/themes/movies/content/stunt.aspx.</code> </p>
<p>The url it should display is <code>http://domain.com/content/stunt.aspx</code>, however a complication arises because the managers want to advertise the url as <code>http://domain.com/stunt.aspx</code> </p>
<p><strong>Make a Placeholder File</strong></p>
<p>The first step was to make a placeholder file in the root called <code>stunt.aspx</code></p>
<p>The page code looks like this (I copied it from another redirecting page):</p>
<pre><code><%@ Page %>
<%--
This page is a placeholder for URL rewriting.
--%>
</code></pre>
<p><strong>SiteUrls_Override.config</strong></p>
<p>In the SiteUrls<code>_</code>Override.config I added an entry to tell CS where the physical page was and what the short url should be. I store all of my /content/ definitions in SiteUrls_Override.config, but I think you could put it in SiteUrls.config if you're careful.</p>
<pre><code><location name="content" path="/content/" themeDir="content">
<url name="contentpart_stunt" path="stunt.aspx" pattern="stunt.aspx" vanity="{2}" physicalPath="##themeDir##" page="stunt.aspx" />
</location>
</code></pre>
<p><strong>SiteUrls.config</strong></p>
<p>In the SiteUrls.config, under the section for root pages, <code><location name="common" path="/" themeDir="common" ></code>, I added this entry:</p>
<pre><code><url name="redirect_stunt" path="/" pattern="stunt.aspx" vanity="{2}" redirect="true" physicalPath="/content/" page="stunt.aspx" />
</code></pre>
<p><strong>Important pieces in this line</strong></p>
<pre><code>redirect="true"
physicalPath="/content/"
</code></pre>
<p>these lines tell it to redirect and where to.</p>
<p><em>More Info:</em>
<a href="http://docs.communityserver.com/customization/understanding-the-siteurls-config-file/" rel="nofollow">http://docs.communityserver.com/customization/understanding-the-siteurls-config-file/</a> </p>