<?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: Redirecting with htaccess</title>
	<link>http://ask.metafilter.com/54282/Redirecting-with-htaccess/</link>
	<description>Comments on Ask MetaFilter post Redirecting with htaccess</description>
	<pubDate>Wed, 03 Jan 2007 09:36:54 -0800</pubDate>
	<lastBuildDate>Wed, 03 Jan 2007 09:36:54 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Redirecting with htaccess</title>
		<link>http://ask.metafilter.com/54282/Redirecting-with-htaccess</link>	
		<description>Taking a site offline with .htaccess. I have a server which is running in production, but I want to take it offline for some maintenance. While I want everyone who calls at any URL to be redirected to index.html, I want admins to be able to view the site in full. &lt;br /&gt;&lt;br /&gt; I think something like this in .htaccess:&lt;br&gt;
RewriteEngine on&lt;br&gt;
RewriteCond %{REMOTE_ADDR} !xxx.xxx.xxx.xxx&lt;br&gt;
RewriteRule [regexp to rewrite anything.php to index.html]&lt;br&gt;
&lt;br&gt;
where xxx.xxx.xxx.xxx is a permitted IP address should work, but it seems not to. Any help? Even if the solution only allows access from localhost (I can run lynx on the server) it&apos;ll do fine.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2007:site.54282</guid>
		<pubDate>Wed, 03 Jan 2007 09:33:14 -0800</pubDate>
		<dc:creator>fightorflight</dc:creator>
		
			<category>Apache</category>
		
			<category>htaccess</category>
		
			<category>web</category>
		
			<category>server</category>
		
			<category>redirect</category>
		
			<category>production</category>
		
	</item> <item>
		<title>By: loiseau</title>
		<link>http://ask.metafilter.com/54282/Redirecting-with-htaccess#817266</link>	
		<description>Are you sure mod_rewrite is installed?&lt;br&gt;
&lt;br&gt;
Personally I&apos;d rename the directory and put up a temporary page in the relevant location, but that&apos;s just a kludge, obvy.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.54282-817266</guid>
		<pubDate>Wed, 03 Jan 2007 09:36:54 -0800</pubDate>
		<dc:creator>loiseau</dc:creator>
	</item><item>
		<title>By: fightorflight</title>
		<link>http://ask.metafilter.com/54282/Redirecting-with-htaccess#817272</link>	
		<description>Yes, mod_rewrite works fine for the rewriting bit, it&apos;s just not letting the correct IPs see the real pages. I don&apos;t want to move the pages for various reasons based on earlier kludges :)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.54282-817272</guid>
		<pubDate>Wed, 03 Jan 2007 09:41:41 -0800</pubDate>
		<dc:creator>fightorflight</dc:creator>
	</item><item>
		<title>By: devbrain</title>
		<link>http://ask.metafilter.com/54282/Redirecting-with-htaccess#817283</link>	
		<description>Just going to index.html gives you difficulties as it&apos;s then difficult to link images in to make it look pretty.  My solution, in use in a few places, is to create an /offline/ directory which can then contain index.html and whatever support files (images, css, js) it needs.&lt;br&gt;
&lt;br&gt;
Here&apos;s my snippet.  From the looks, your ! might just need to be a !=.  Also note that my solution maps *everything* to the offline page, not just pages that end in php.  Since you don&apos;t list that rule in full the problem could also exist there.&lt;br&gt;
&lt;br&gt;
I&apos;ve included the second RewriteCond so you can put a number of &quot;admin&quot; IP addresses to permit.  Of course, add in your 127.0.0.1 as needed.&lt;br&gt;
&lt;br&gt;
RewriteEngine On&lt;br&gt;
RewriteCond  %{REMOTE_ADDR}  !=12.12.12.12&lt;br&gt;
RewriteCond  %{REMOTE_ADDR}  !=23.23.23.23&lt;br&gt;
RewriteCond  %{REQUEST_URI}  !^/offline&lt;br&gt;
RewriteRule  ^.*  /offline/ [R]</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.54282-817283</guid>
		<pubDate>Wed, 03 Jan 2007 09:47:48 -0800</pubDate>
		<dc:creator>devbrain</dc:creator>
	</item><item>
		<title>By: twiki</title>
		<link>http://ask.metafilter.com/54282/Redirecting-with-htaccess#817696</link>	
		<description>I&apos;ve done this a ton of times and I&apos;ve never used mod rewrite but it has always worked perfectly.&lt;br&gt;
&lt;br&gt;
Here&apos;s what I do:&lt;br&gt;
&lt;br&gt;
1. Create a &quot;down for business&quot; page in a completely different place, in my case I created a www2.mysite.com and put the &quot;we&apos;re down right now!&quot; page and images there.&lt;br&gt;
&lt;br&gt;
2. Change the order to deny, allow&lt;br&gt;
&lt;br&gt;
3. Allow the IPs of the testers&lt;br&gt;
&lt;br&gt;
4. Set a 403 error document location of www2.mysite.com&lt;br&gt;
&lt;br&gt;
Here&apos;s the actual code (replace XX with the IPs you want to allow):&lt;br&gt;
&lt;br&gt;
order deny,allow&lt;br&gt;
deny from all&lt;br&gt;
#tester IPs&lt;br&gt;
allow from XXX.XXX.XXX.XXX&lt;br&gt;
allow from XXX.XXX.XXX.XXX&lt;br&gt;
ErrorDocument 403 http://www2.mysite.com/</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.54282-817696</guid>
		<pubDate>Wed, 03 Jan 2007 14:07:53 -0800</pubDate>
		<dc:creator>twiki</dc:creator>
	</item><item>
		<title>By: fightorflight</title>
		<link>http://ask.metafilter.com/54282/Redirecting-with-htaccess#818360</link>	
		<description>Thanks very much everyone. Devbrain yours worked a treat. I&apos;m sure the error plan would work too, twiki, but I wanted to keep it all on the same box.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.54282-818360</guid>
		<pubDate>Thu, 04 Jan 2007 07:50:46 -0800</pubDate>
		<dc:creator>fightorflight</dc:creator>
	</item><item>
		<title>By: mrapache</title>
		<link>http://ask.metafilter.com/54282/Redirecting-with-htaccess#881731</link>	
		<description>There is a whole section on doing exactly this on the &lt;a href=&quot;http://www.askapache.com/2006/htaccess/htaccesselite-ultimate-htaccess-article.html#for-apache-webmasters&quot;&gt;Ultimate htaccess article&lt;/a&gt;:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;&lt;a href=&quot;http://www.askapache.com/2006/htaccess/htaccesselite-ultimate-htaccess-article.html#redirect-all-to-alternate-file&quot;&gt;Redirect Everyone but you to alternate page on your server.&lt;/a&gt; &lt;/strong&gt;&lt;br&gt;
&lt;br&gt;
RewriteEngine On&lt;br&gt;
RewriteBase /&lt;br&gt;
RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1&lt;br&gt;
RewriteCond %{REQUEST_URI} !/temporary-offline\.html$&lt;br&gt;
RewriteRule .* /temporary-offline.html [R=302,L]&lt;br&gt;
&lt;br&gt;
That is cool because it redirects users to the page /temporary-offline.html unless the user is coming from a certain IP address.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.54282-881731</guid>
		<pubDate>Wed, 14 Mar 2007 06:09:33 -0800</pubDate>
		<dc:creator>mrapache</dc:creator>
	</item>
	</channel>
</rss>
