<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

      <title>Comments on: I'd like to redirect an entire directory to one specific file.</title>
      <link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file/</link>
      <description>Comments on Ask MetaFilter post I'd like to redirect an entire directory to one specific file.</description>
	  	  <pubDate>Tue, 13 Mar 2007 20:19:28 -0800</pubDate>
      <lastBuildDate>Tue, 13 Mar 2007 20:19:28 -0800</lastBuildDate>
      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>

<item>
  	<title>Question: I&apos;d like to redirect an entire directory to one specific file.</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file</link>	
  	<description>301 redirectrs in .htaccess: how do I redirect calendar/* to /calendar.html ?  I&apos;ve tried modifying various examples online and they result in either &quot;internal server error&quot; or a 404 caused by incorrectly redirecting /calendar/* to /calendar.html/* . Two examples from the experimentation (I&apos;m in over my head; I just want this to work):&lt;br&gt;
&lt;br&gt;
# redirect 301 /calendar http://www.domain.com/calendar.html&lt;br&gt;
# 404 due to mistake above.&lt;br&gt;
&lt;br&gt;
# RedirectMatch 301 ^/calendar/(.*).htm$ http://www.domain.com/calendar.html [L]&lt;br&gt;
# internal server error</description>
  	<guid isPermaLink="false">post:ask.metafilter.com,2008:site.58651</guid>
  	<pubDate>Tue, 13 Mar 2007 20:10:18 -0800</pubDate>
  	<dc:creator>Tuwa</dc:creator>
	
	<category>htaccess</category>
	
	<category>301redirect</category>
	
	<category>redirect</category>
	
	<category>regex</category>
	
	<category>wildcard</category>
	
	<category>regularexpression</category>
	
	<category>resolved</category>
	
</item>
<item>
  	<title>By: niles</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881454</link>	
  	<description>&lt;strong&gt;Don&apos;t worry about URL matching&lt;/strong&gt; - just redirect the entire calendar folder:&lt;br&gt;
&lt;blockquote&gt;&lt;br&gt;
RewriteRule ^([a-z]+) /calendar.html [R,NC,L]&lt;br&gt;
&lt;/blockquote&gt;&lt;br&gt;
&lt;br&gt;
&lt;em&gt;should&lt;/em&gt; do the trick, but I could be wrong.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881454</guid>
  	<pubDate>Tue, 13 Mar 2007 20:19:28 -0800</pubDate>
  	<dc:creator>niles</dc:creator>
</item>
<item>
  	<title>By: niles</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881457</link>	
  	<description>Yep, just tested it, and it appears to work great.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881457</guid>
  	<pubDate>Tue, 13 Mar 2007 20:23:52 -0800</pubDate>
  	<dc:creator>niles</dc:creator>
</item>
<item>
  	<title>By: Tuwa</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881462</link>	
  	<description>I tried it and it didn&apos;t.  I guess I should have given more detail: I&apos;m moving away from a loathsome Outlook-based calendaring non-solution which generates a metric ton of files and can apparently only be maintained from one computer (?).  In any case it&apos;s slow and cumbersome and I have all these filenames like 2006d10.htm .&lt;br&gt;
&lt;br&gt;
Also I know next to nothing about .htaccess.  Given the filenames, would the bit to add be &lt;cite&gt;RewriteRule ^([a-z0-9]+) /calendar.html [R,NC,L]&lt;/cite&gt; ?  And is that all that I add to the .htaccess file?  My other rewrites look like  &lt;cite&gt;redirect 301 /body.html http://www.domain.com/index.html&lt;/cite&gt;&lt;br&gt;
&lt;br&gt;
Also, would this be a separate .htaccess to go in the subdirectory or in root?&lt;br&gt;
&lt;br&gt;
Thanks.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881462</guid>
  	<pubDate>Tue, 13 Mar 2007 20:32:19 -0800</pubDate>
  	<dc:creator>Tuwa</dc:creator>
</item>
<item>
  	<title>By: boaz</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881467</link>	
  	<description>For that second match, I think that [L] at the end of the RedirectMatch is causing your error; that&apos;s a mod_rewrite thing and not really relevant to Redirect.  Other than that, it looks, well, a bit odd but workable.  It will, however, only redirect URLs that end in &apos;.htm&apos;, which I&apos;m not sure is right. It seems like &lt;br&gt;
&lt;br&gt;
&lt;code&gt;RedirectMatch 301 ^/calendar http://www.mydomain.com/calendar.html&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
is all you really need.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881467</guid>
  	<pubDate>Tue, 13 Mar 2007 20:40:04 -0800</pubDate>
  	<dc:creator>boaz</dc:creator>
</item>
<item>
  	<title>By: Rhomboid</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881468</link>	
  	<description>Your second example gave an error because you can&apos;t use just a RedirectMatch.  RedirectMatch can only be used as a preface to RewriteRule.  You should just use that instead.&lt;br&gt;
&lt;br&gt;
Furthermore, you should stick to specifying the entire hostname + pathname in the redirect.  It violates the HTTP RFC to specify just &amp;quot;/calendar.html&amp;quot; without a hostname in the redirect.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881468</guid>
  	<pubDate>Tue, 13 Mar 2007 20:40:10 -0800</pubDate>
  	<dc:creator>Rhomboid</dc:creator>
</item>
<item>
  	<title>By: boaz</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881469</link>	
  	<description>Um, on second thought, that&apos;s not right, since it&apos;ll just keep redirecting.  An extra slash will stop that:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;RedirectMatch 301 ^/calendar/ http://www.mydomain.com/calendar.html&lt;/code&gt;</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881469</guid>
  	<pubDate>Tue, 13 Mar 2007 20:41:22 -0800</pubDate>
  	<dc:creator>boaz</dc:creator>
</item>
<item>
  	<title>By: Rhomboid</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881471</link>	
  	<description>Oops, I meant RewriteCond where I wrote RedirectMatch.  The reason RedirectMAtch gave you a server error is because it does not take the third argument (i.e. [foo]).</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881471</guid>
  	<pubDate>Tue, 13 Mar 2007 20:42:34 -0800</pubDate>
  	<dc:creator>Rhomboid</dc:creator>
</item>
<item>
  	<title>By: niles</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881472</link>	
  	<description>Assuming your files are in the &amp;quot;calendar&amp;quot; folder, you can place a separate .htaccess file in that folder to apply to any url contained within the calendar folder, which bypasses any URL rewriting confusion.&lt;br&gt;
&lt;br&gt;
I set this up on my server, so if you go to the url &lt;a href=&quot;nicholas.sideras.org/calendar/randomfile.html&quot;&gt;nicholas.sideras.org/calendar/randomfile.html&lt;/a&gt;, you get sent to &lt;a href=&quot;http://nicholas.sideras.org/calendar.html&quot;&gt;http://nicholas.sideras.org/calendar.html&lt;/a&gt;. You can grab the .htaccess file &lt;a href=&quot;http://nicholas.sideras.org/calendar-htaccess.txt&quot;&gt;here&lt;/a&gt;.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881472</guid>
  	<pubDate>Tue, 13 Mar 2007 20:42:40 -0800</pubDate>
  	<dc:creator>niles</dc:creator>
</item>
<item>
  	<title>By: niles</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881473</link>	
  	<description>&lt;small&gt;Though, reading Rhomboid&apos;s comments, this may not be the best/most-correct way to do it.&lt;/small&gt;</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881473</guid>
  	<pubDate>Tue, 13 Mar 2007 20:43:57 -0800</pubDate>
  	<dc:creator>niles</dc:creator>
</item>
<item>
  	<title>By: mrg</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881474</link>	
  	<description>are all the extensions the same? I did something similar by doing &lt;tt&gt;RedirectMatch /*.php http://the/url&lt;/tt&gt;. In my case, I wanted to redirect all the PHP stuff on a site to another location (I transfered hosting and needed to keep the old vhost up). Maybe you could do &lt;tt&gt;/calendar/*.htm*&lt;/tt&gt;? RewriteRule is part of mod_rewrite, which you may or may not have (given that it didn&apos;t work, you may not).</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881474</guid>
  	<pubDate>Tue, 13 Mar 2007 20:45:20 -0800</pubDate>
  	<dc:creator>mrg</dc:creator>
</item>
<item>
  	<title>By: Tuwa</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881483</link>	
  	<description>Thanks, everyone.  Boaz, your solution &amp;amp; addendum worked.  Niles, I can see that yours does too, so thanks for that.&lt;br&gt;
&lt;br&gt;
Rhomboid, do you mean that the domain should be speficied on both sides of the rewrite/redirect?  (e.g. &amp;quot;redirect 301 /body.html http://www.domain.com/index.html&amp;quot; should be &amp;quot;redirect 301 http://www.domain.com/body.html http://www.domain.com/index.html&amp;quot; instead?)  I tried listing the domain on both sides and the redirect quit working.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881483</guid>
  	<pubDate>Tue, 13 Mar 2007 20:58:19 -0800</pubDate>
  	<dc:creator>Tuwa</dc:creator>
</item>
<item>
  	<title>By: mrapache</title>
  	<link>http://ask.metafilter.com/58651/Id-like-to-redirect-an-entire-directory-to-one-specific-file#881726</link>	
  	<description>&lt;strong&gt;This is an easy one!&lt;/strong&gt;&lt;br&gt;
&lt;br&gt;
From: &lt;a title=&quot;Ultimate apache htaccess&quot; href=&quot;http://www.askapache.com/2006/htaccess/htaccesselite-ultimate-htaccess-article.html&quot;&gt;Ultimate htaccess Article&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
RedirectMatch 301 ^/calendar(.*) http://www.askapache.com/calendar.html&lt;br&gt;
&lt;br&gt;
Or &lt;br&gt;
&lt;br&gt;
RewriteEngine On&lt;br&gt;
RewriteBase /&lt;br&gt;
RewriteCond %{REQUEST_URI} !^/calendar\.html$ [NC]&lt;br&gt;
RewriteRule ^calendar.* http://askapache.com/calendar.html [R=301,NC,L]&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Redirect and RedirectMatch directives are from the module mod_alias, while the rewrite* directives are from the module mod_rewrite.. Both of these will perform a 301 permanent redirect, which will update search engines.  You could change the 301 to 302 for temporary.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.58651-881726</guid>
  	<pubDate>Wed, 14 Mar 2007 06:03:55 -0800</pubDate>
  	<dc:creator>mrapache</dc:creator>
</item>

    </channel>
</rss>
