<?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: %{QUERY_STRING} the Hivemind</title>
      <link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind/</link>
      <description>Comments on Ask MetaFilter post %{QUERY_STRING} the Hivemind</description>
	  	  <pubDate>Wed, 20 Feb 2008 12:44:48 -0800</pubDate>
      <lastBuildDate>Wed, 20 Feb 2008 12:44:48 -0800</lastBuildDate>
      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>

<item>
  	<title>Question: %{QUERY_STRING} the Hivemind</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind</link>	
  	<description>Mod_rewrite &amp;amp; query strings: Just when I thought I had it figured out... I was wanting to redirect from old files [home|fotos|foo|bar].asp with query string variables id &amp;amp; lid to a new &amp;amp; nicer URL /XXX/[index|pics|foozie|barrie], where XXX was an alias dependant on the two values. So I managed to suss out the following&lt;br&gt;
&lt;br&gt;
&lt;code&gt;  RewriteCond %{QUERY_STRING}  ^id=123&amp;amp;lid=456$ [NC]&lt;br&gt;
  RewriteRule ^home\.asp$ /whatever/index? [R=301,NC,L]&lt;br&gt;
  RewriteRule ^fotos\.asp$ /whatever/pics? [R=301,NC,L]&lt;br&gt;
  RewriteRule ^foo\.asp$ /whatever/foozie? [R=301,NC,L]&lt;br&gt;
  RewriteRule ^bar\.asp$ /whatever/barrie? [R=301,NC,L]&lt;br&gt;
&lt;br&gt;
  RewriteCond %{QUERY_STRING}  ^id=456&amp;amp;lid=789$ [NC]&lt;br&gt;
  RewriteRule ^home\.asp$ /whatever2/index? [R=301,NC,L]&lt;br&gt;
  RewriteRule ^fotos\.asp$ /whatever2/pics? [R=301,NC,L]&lt;br&gt;
  RewriteRule ^foo\.asp$ /whatever2/fooozie? [R=301,NC,L]&lt;br&gt;
  RewriteRule ^bar\.asp$ /whatever2/barrie? [R=301,NC,L]&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
which works nicely. Yay me.&lt;br&gt;
&lt;br&gt;
But now I discovered some search results where variables other than id &amp;amp; lid are appended to the query string. I don&apos;t give a flying rat&apos;s arse about these variables. I just want to be redirected to /whatever/index if the old request was for home.asp and id=123 &amp;amp; lid=456.&lt;br&gt;
&lt;br&gt;
I&apos;ve tried &lt;br&gt;
&lt;code&gt;  RewriteCond %{QUERY_STRING}  ^id=456&amp;amp;lid=789.* [NC]&lt;/code&gt;&lt;br&gt;
and&lt;br&gt;
&lt;code&gt;  RewriteCond %{QUERY_STRING}  ^id=456&amp;amp;lid=789? [NC,OR]&lt;br&gt;
  RewriteCond %{QUERY_STRING}  ^id=456&amp;amp;lid=789.* [NC]&lt;/code&gt;&lt;br&gt;
as well as various other screwups. At this point I&apos;m getting blurry-eyed and have lost track of all the combinations I&apos;ve attempted.&lt;br&gt;
&lt;br&gt;
What&apos;s the totally obvious mod_rewrite voodoo I&apos;ve overlooked?</description>
  	<guid isPermaLink="false">post:ask.metafilter.com,2008:site.84141</guid>
  	<pubDate>Wed, 20 Feb 2008 12:23:37 -0800</pubDate>
  	<dc:creator>romakimmy</dc:creator>
	
	<category>mod_rewrite</category>
	
	<category>htaccess</category>
	
	<category>apache</category>
	
</item>
<item>
  	<title>By: team lowkey</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind#1245501</link>	
  	<description>Um, have you tried just id=456&amp;amp;lid=789 , without anything after it?</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.84141-1245501</guid>
  	<pubDate>Wed, 20 Feb 2008 12:44:48 -0800</pubDate>
  	<dc:creator>team lowkey</dc:creator>
</item>
<item>
  	<title>By: romakimmy</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind#1245539</link>	
  	<description>Just tried it, and matches the query string when the old request is for home.asp, but for the other files it&apos;s defaulting to the first set of rules. i.e. fotos.asp?id=456&amp;amp;lid=789 is redirecting to /whatever/pics instead of /whatever2/pics.&lt;br&gt;
&lt;br&gt;
Should I be capturing &amp;amp; referencing the matched query string somehow in the RewriteRule?</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.84141-1245539</guid>
  	<pubDate>Wed, 20 Feb 2008 13:06:53 -0800</pubDate>
  	<dc:creator>romakimmy</dc:creator>
</item>
<item>
  	<title>By: autojack</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind#1245621</link>	
  	<description>I don&apos;t have an answer for your particular question, but I have a suggestion for where you could get one:&lt;br&gt;
&lt;br&gt;
#apache on the IRC server irc.openprojects.net&lt;br&gt;
&lt;br&gt;
That channel has been, without question, the most useful tech help channel I&apos;ve ever found on IRC. And mod_rewrite questions are 4/5 the reason I go in there. You can usually get a quick, correct answer without a lot of excessive chatter.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.84141-1245621</guid>
  	<pubDate>Wed, 20 Feb 2008 13:53:25 -0800</pubDate>
  	<dc:creator>autojack</dc:creator>
</item>
<item>
  	<title>By: team lowkey</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind#1245666</link>	
  	<description>I&apos;m not sure I&apos;m following what you&apos;re after anymore. Does this get you the result you want?&lt;br&gt;
&lt;br&gt;
RewriteCond %{QUERY_STRING} id=123 [NC]&lt;br&gt;
RewriteCond %{QUERY_STRING} lid=456 [NC]&lt;br&gt;
RewriteRule ^home\.asp /whatever/index? [R=301,NC,L]&lt;br&gt;
RewriteRule ^fotos\.asp /whatever/pics? [R=301,NC,L]&lt;br&gt;
&lt;br&gt;
RewriteCond %{QUERY_STRING} id=456 [NC]&lt;br&gt;
RewriteCond %{QUERY_STRING} lid=789 [NC]&lt;br&gt;
RewriteRule ^home\.asp /whatever2/index? [R=301,NC,L]&lt;br&gt;
RewriteRule ^fotos\.asp /whatever2/pics? [R=301,NC,L]</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.84141-1245666</guid>
  	<pubDate>Wed, 20 Feb 2008 14:20:04 -0800</pubDate>
  	<dc:creator>team lowkey</dc:creator>
</item>
<item>
  	<title>By: so</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind#1246005</link>	
  	<description>Did you know that the RewriteCond only applies to the next RewriteRule (only the very next one, and not the remaining 3 in each section)?</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.84141-1246005</guid>
  	<pubDate>Wed, 20 Feb 2008 20:02:47 -0800</pubDate>
  	<dc:creator>so</dc:creator>
</item>
<item>
  	<title>By: meta_eli</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind#1246030</link>	
  	<description>I think so has identified the problem there. You can stack several RewriteConds together, but they all only apply to the single, following RewriteRule</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.84141-1246030</guid>
  	<pubDate>Wed, 20 Feb 2008 20:30:43 -0800</pubDate>
  	<dc:creator>meta_eli</dc:creator>
</item>
<item>
  	<title>By: romakimmy</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind#1246199</link>	
  	<description>Yeah, I found that and the fact that RewriteRule is matched before RewriteCond last night, but it was late to fuzz around any more &amp;amp; I decided to go to bed. (Not that sleeping was restful - I fucking dreamt about about mod_rewrite all night. /cranky)&lt;br&gt;
&lt;br&gt;
Since I won&apos;t have access to RewriteMap, I&apos;ll have to throw in the towel and write a quick script today.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.84141-1246199</guid>
  	<pubDate>Thu, 21 Feb 2008 03:01:50 -0800</pubDate>
  	<dc:creator>romakimmy</dc:creator>
</item>
<item>
  	<title>By: so</title>
  	<link>http://ask.metafilter.com/84141/QUERYSTRING-the-Hivemind#1246248</link>	
  	<description>rats on bad sleep!&lt;br&gt;
&lt;br&gt;
Maybe I&apos;m missing the obvious, but couldn&apos;t you just &amp;quot;unroll&amp;quot; your lines?&lt;br&gt;
&lt;code&gt;&lt;br&gt;
RewriteCond %{QUERY_STRING} ^id=123&amp;amp;lid=456$ [NC]&lt;br&gt;
RewriteRule ^home\.asp$ /whatever/index? [R=301,NC,L]&lt;br&gt;
&lt;br&gt;
RewriteCond %{QUERY_STRING} ^id=123&amp;amp;lid=456$ [NC]&lt;br&gt;
RewriteRule ^fotos\.asp$ /whatever/pics? [R=301,NC,L]&lt;br&gt;
&lt;br&gt;
RewriteCond %{QUERY_STRING} ^id=123&amp;amp;lid=456$ [NC]&lt;br&gt;
RewriteRule ^foo\.asp$ /whatever/foozie? [R=301,NC,L]&lt;br&gt;
&lt;br&gt;
RewriteCond %{QUERY_STRING} ^id=123&amp;amp;lid=456$ [NC]&lt;br&gt;
RewriteRule ^bar\.asp$ /whatever/barrie? [R=301,NC,L]&lt;br&gt;
&lt;br&gt;
...&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Of course you&apos;re right about getting into RewriteMap territory here!&lt;br&gt;
&lt;br&gt;
coffee == good  ;)&lt;br&gt;
&lt;br&gt;
-s.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.84141-1246248</guid>
  	<pubDate>Thu, 21 Feb 2008 05:57:03 -0800</pubDate>
  	<dc:creator>so</dc:creator>
</item>

    </channel>
</rss>
