<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://shazwazza.com/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Shazwazza</title>
    <link>https://shazwazza.com/</link>
    <description>My blog which is pretty much just all about coding</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <image>
      <url>/media/0libq25y/frog.png?rmode=max&amp;v=1da0e911f4e6890</url>
      <title>Shazwazza</title>
      <link>https://shazwazza.com/</link>
    </image>
    <item>
      <guid isPermaLink="false">1202</guid>
      <link>https://shazwazza.com/post/excluding-pages-with-url-rewriting/</link>
      <category>Web Development</category>
      <title>Excluding pages with URL Rewriting</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;Today we had a mini site which the promotion had completed, but the site was to stay live with a few of the content pages staying live for people who come to view it.&lt;/p&gt;  &lt;p&gt;Because the site was only a few pages there isn’t a CMS back-end, it’s just flat ASPX pages are stored in a single folder.    &lt;br /&gt;The problem is, that the pages which need to be available are also in the folder which the pages which are not longer accessible are.&lt;/p&gt;  &lt;p&gt;There is a few ways in which I can take &lt;em&gt;down&lt;/em&gt; the pages which people aren’t meant to access, firstly I could just delete them. That’d work, but that’d be a 404 error which isn’t really a good user experience (I could set the 404 redirect to be the home page, but the browser would still receive a 404 HTTP status).&lt;/p&gt;  &lt;p&gt;So the next option is URL Redirection, lets crack out our UrlRewriting.config file and set up a rule. We’ll start with a rule like this:&lt;/p&gt;  &lt;pre&gt;&amp;lt;add name=&amp;quot;RedirAllIndexedPagesToDefault&amp;quot; 
   virtualURL=&amp;quot;^(.*)/pages/(.*)&amp;quot; 
   destinationUrl=&amp;quot;$1/default.aspx&amp;quot; 
   redirectMode=&amp;quot;Permanent&amp;quot; 
   redirect=&amp;quot;Domain&amp;quot; 
   ignoreCase=&amp;quot;true&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;There, that’ll handle &lt;strong&gt;everything&lt;/strong&gt; in our pages folder, but it doesn’t help with the pages which I want accessible. Say the pages I want accessible are TermsAndConditions.aspx and PrivacyPolicy.aspx, but I don’t want Entry.aspx accessible. 

  &lt;br /&gt;It’s just a matter of modifying my &lt;strong&gt;virtualURL&lt;/strong&gt; to be a bit stricter, so now it looks like this:&lt;/p&gt;

&lt;pre&gt;&amp;lt;add name=&amp;quot;RedirAllIndexedPagesToDefault&amp;quot; 
   virtualURL=&amp;quot;^(.*)/pages/&lt;strong&gt;(?![TP.*])&lt;/strong&gt;(.*)&amp;quot; 
   destinationUrl=&amp;quot;$1/default.aspx&amp;quot; 
   redirectMode=&amp;quot;Permanent&amp;quot; 
   redirect=&amp;quot;Domain&amp;quot; 
   ignoreCase=&amp;quot;true&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;Now you’ll not be able to get to Entry.aspx, but the other two pages will still work just fine.&lt;/p&gt;

&lt;p&gt;Sure it’s not great if you’ve got lots of pages (and if you did have lots of pages I’d hope there was a CMS to deal with it), but it’s good for mini sites which you want some pages but not others in a folder accessible.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
  </channel>
</rss>