Note that there are some explanatory texts on larger screens.

plurals
  1. POMoving IIS7 url rewrite section out of the web.config file
    primarykey
    data
    text
    <p>I have made a config section in my web.config file that has all rewrite rules like the following</p> <pre><code>&lt;rewrite&gt; &lt;outboundRules&gt; &lt;rule name="OutboundRewriteCatalogURL" preCondition="ResponseIsHtml1"&gt; &lt;match filterByTags="A" pattern="^(.*/)Catalog\.aspx\?Catalog=([^=&amp;amp;]+)&amp;amp;(?:amp;)?Title=([^=&amp;amp;]+)$" /&gt; &lt;action type="Rewrite" value="{R:1}ctlg/{R:2}/{R:3}/" /&gt; &lt;/rule&gt; &lt;rule name="OutboundRewriteCategoryURL" preCondition="ResponseIsHtml1"&gt; &lt;match filterByTags="A" pattern="^(.*/)ProductList\.aspx\?Catalog=([^=&amp;amp;]+)&amp;amp;(?:amp;)?Category=([^=&amp;amp;]+)&amp;amp;(?:amp;)?Title=([^=&amp;amp;]+)$" /&gt; &lt;action type="Rewrite" value="{R:1}categ/{R:2}/{R:3}/{R:4}/" /&gt; &lt;/rule&gt; &lt;rule name="OutboundRewriteFullProductURL" preCondition="ResponseIsHtml1"&gt; &lt;match filterByTags="A, Form, Img" pattern="^(.*/)Product\.aspx\?Catalog=([^=&amp;amp;]+)&amp;amp;(?:amp;)?Category=([^=&amp;amp;]+)&amp;amp;(?:amp;)?Product=([^=&amp;amp;]+)&amp;amp;(?:amp;)?Title=([^=&amp;amp;]+)$" /&gt; &lt;action type="Rewrite" value="{R:1}prd/{R:2}-{R:3}-{R:4}/{R:5}/" /&gt; &lt;/rule&gt; &lt;preConditions&gt; &lt;preCondition name="ResponseIsHtml1"&gt; &lt;add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /&gt; &lt;/preCondition&gt; &lt;/preConditions&gt; &lt;/outboundRules&gt; &lt;rules&gt; &lt;rule name="RedirectCatalogURL" stopProcessing="true"&gt; &lt;match url="^Catalog\.aspx$" /&gt; &lt;conditions&gt; &lt;add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /&gt; &lt;add input="{QUERY_STRING}" pattern="^Catalog=([^=&amp;amp;]+)&amp;amp;Title=([^=&amp;amp;]+)$" /&gt; &lt;/conditions&gt; &lt;action type="Redirect" url="Catalog/{C:1}/{C:2}" appendQueryString="false" /&gt; &lt;/rule&gt; &lt;rule name="RewriteCatalogURL" stopProcessing="true"&gt; &lt;match url="^ctlg/([^/]+)/([^/]+)/?$" /&gt; &lt;conditions&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt; &lt;/conditions&gt; &lt;action type="Rewrite" url="Catalog.aspx?Catalog={R:1}&amp;amp;Title={R:2}" /&gt; &lt;/rule&gt; &lt;rule name="RedirectCategoryURL" stopProcessing="true"&gt; &lt;match url="^ProductList\.aspx$" /&gt; &lt;conditions&gt; &lt;add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /&gt; &lt;add input="{QUERY_STRING}" pattern="^Catalog=([^=&amp;amp;]+)&amp;amp;Category=([^=&amp;amp;]+)&amp;amp;Title=([^=&amp;amp;]+)$" /&gt; &lt;/conditions&gt; &lt;action type="Redirect" url="categ/{C:1}/{C:2}/{C:3}" appendQueryString="false" /&gt; &lt;/rule&gt; &lt;rule name="RewriteCategoryURL" stopProcessing="true"&gt; &lt;match url="^categ/([^/]+)/([^/]+)/([^/]+)/?$" /&gt; &lt;conditions&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt; &lt;/conditions&gt; &lt;action type="Rewrite" url="ProductList.aspx?Catalog={R:1}&amp;amp;Category={R:2}&amp;amp;Title={R:3}" /&gt; &lt;/rule&gt; &lt;rule name="RedirectProductURL" stopProcessing="true"&gt; &lt;match url="^Product\.aspx$" /&gt; &lt;conditions&gt; &lt;add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /&gt; &lt;add input="{QUERY_STRING}" pattern="^Catalog=([^=&amp;amp;]+)&amp;amp;Category=([^=&amp;amp;]+)&amp;amp;Product=([^=&amp;amp;]+)&amp;amp;Title=([^=&amp;amp;]+)$" /&gt; &lt;/conditions&gt; &lt;action type="Redirect" url="prd/{C:1}-{C:2}-{C:3}/{C:4}" appendQueryString="false" /&gt; &lt;/rule&gt; &lt;rule name="RewriteProductURL" stopProcessing="true"&gt; &lt;match url="^prd/([^/]+)-([^/]+)-([^/]+)/([^/]+)/?$" /&gt; &lt;conditions&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt; &lt;/conditions&gt; &lt;action type="Rewrite" url="Product.aspx?Catalog={R:1}&amp;amp;Category={R:2}&amp;amp;Product={R:3}&amp;amp;Title={R:4}" /&gt; &lt;/rule&gt; &lt;/rules&gt; &lt;/rewrite&gt; </code></pre> <p>Its very nice and working good but I dont want to have all these stuff in the web.config file , is there a way to have rewrite configuration in an external config file?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload