<?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 users by IP in Apache</title>
	<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache/</link>
	<description>Comments on Ask MetaFilter post Redirecting users by IP in Apache</description>
	<pubDate>Mon, 12 May 2008 13:42:32 -0800</pubDate>
	<lastBuildDate>Mon, 12 May 2008 13:42:32 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Redirecting users by IP in Apache</title>
		<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache</link>	
		<description>How do I redirect incoming website visitors to an external site by IP address?  &lt;br /&gt;&lt;br /&gt; I&apos;m the general sysadmin here and don&apos;t do much web stuff other than simple content updating, but I think I&apos;m on the right track with adding this bit of mod_rewrite code to the end of the httpd.conf file...&lt;br&gt;
&lt;br&gt;
&lt;ifmodule&gt;&lt;br&gt;
RewriteEngine on&lt;br&gt;
RewriteCond %{REMOTE_ADDR} ^12\.345\.678\.9$&lt;br&gt;
RewriteCond %{REQUEST_URI} ^/index.php$ [NC]&lt;br&gt;
RewriteRule ^/(.*) http://test.foo.com/$1 [R]&lt;br&gt;
&lt;/ifmodule&gt;&lt;br&gt;
&lt;br&gt;
Any ideas why this isn&apos;t working?&lt;br&gt;
&lt;br&gt;
(apache 1.3.33 on OS X)</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.91212</guid>
		<pubDate>Mon, 12 May 2008 13:16:56 -0800</pubDate>
		<dc:creator>Oktober</dc:creator>
		
			<category>www</category>
		
			<category>apache</category>
		
			<category>perl</category>
		
			<category>webmaster</category>
		
			<category>worldwideweb</category>
		
	</item> <item>
		<title>By: alan</title>
		<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache#1337660</link>	
		<description>Try turning on logging while troubleshooting your rewrites.  (Level 9 will give you the most detailed logging)&lt;br&gt;
&lt;br&gt;
    RewriteEngine On    &lt;br&gt;
    RewriteLog /tmp/log.txt&lt;br&gt;
    RewriteLogLevel 9    &lt;br&gt;
&lt;br&gt;
This will log every step apache takes while churning your request through mod_rewrite. You get to see what apache is actually doing and you should be able to figure out where your logic is failing .  Bonus OS X tip; use the Console app in the &quot;/Application/Utilities&quot; folder to monitor the log file.  It&apos;s kind of a GUI for tail.&lt;br&gt;
&lt;br&gt;
Don&apos;t forget to turn logging off once you go to production, as it&apos;ll make your server crawl.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91212-1337660</guid>
		<pubDate>Mon, 12 May 2008 13:42:32 -0800</pubDate>
		<dc:creator>alan</dc:creator>
	</item><item>
		<title>By: autojack</title>
		<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache#1337661</link>	
		<description>RewriteEngine On&lt;br&gt;
RewriteCond %{REMOTE_ADDR} ^71\.5\.1\.212$&lt;br&gt;
RewriteRule .* http://www.google.com</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91212-1337661</guid>
		<pubDate>Mon, 12 May 2008 13:47:18 -0800</pubDate>
		<dc:creator>autojack</dc:creator>
	</item><item>
		<title>By: autojack</title>
		<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache#1337667</link>	
		<description>The above is known to work for me, so at worst it seems you have a problem with your REQUEST_URI line. If you don&apos;t need that part (if you want to redirect all requests), you can leave it out and it should work.&lt;br&gt;
&lt;br&gt;
Otherwise, when in doubt, #apache on irc.openprojects.net is my go-to source for mod_rewrite help.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91212-1337667</guid>
		<pubDate>Mon, 12 May 2008 13:50:52 -0800</pubDate>
		<dc:creator>autojack</dc:creator>
	</item><item>
		<title>By: quiet</title>
		<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache#1337895</link>	
		<description>The rewrite rules look fine to me although I&apos;ve been working on Apache 2 for a while so there might be some 1.3 silliness going on. &lt;br&gt;
&lt;br&gt;
I&apos;d guess that the problem is that the REMOTE_ADDR is not the value you&apos;re expecting. Perhaps there&apos;s a proxy server in the way? An easy way to test would be to temporarily change the RewriteRule to read:&lt;br&gt;
&lt;br&gt;
RewriteRule ^/(.*) http://test.foo.com/$1?%{REMOTE_ADDR} [R]&lt;br&gt;
&lt;br&gt;
and load the page up in your favourite browser to see what happens.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91212-1337895</guid>
		<pubDate>Mon, 12 May 2008 17:26:36 -0800</pubDate>
		<dc:creator>quiet</dc:creator>
	</item><item>
		<title>By: Oktober</title>
		<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache#1338507</link>	
		<description>I&apos;ll check that out, but the REMOTE_ADDR is my own machine, and the server is on the same subnet as I am.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91212-1338507</guid>
		<pubDate>Tue, 13 May 2008 07:04:00 -0800</pubDate>
		<dc:creator>Oktober</dc:creator>
	</item><item>
		<title>By: systematic</title>
		<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache#1339124</link>	
		<description>Not that I don&apos;t love mod_rewrite, but if REMOTE_ADDR is your own machine wouldn&apos;t it be easier to just use something like this:&lt;br&gt;
&lt;a href=&quot;http://pastie.caboo.se/196390&quot;&gt;http://pastie.caboo.se/196390&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://httpd.apache.org/docs/1.3/vhosts/name-based.html&quot;&gt;http://httpd.apache.org/docs/1.3/vhosts/name-based.html&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://httpd.apache.org/docs/2.0/mod/core.html#servername&quot;&gt;http://httpd.apache.org/docs/2.0/mod/core.html#servername&lt;/a&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91212-1339124</guid>
		<pubDate>Tue, 13 May 2008 13:55:38 -0800</pubDate>
		<dc:creator>systematic</dc:creator>
	</item><item>
		<title>By: Oktober</title>
		<link>http://ask.metafilter.com/91212/Redirecting-users-by-IP-in-Apache#1342657</link>	
		<description>it&apos;s my machine for testing purposes, but eventually, i&apos;ll have to have multiple staff members hitting it.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91212-1342657</guid>
		<pubDate>Fri, 16 May 2008 10:46:28 -0800</pubDate>
		<dc:creator>Oktober</dc:creator>
	</item>
	</channel>
</rss>
