I have a CMS that writes static files. We're trying to provide a stripped version of the site for mobile browsers and we're doing this with a perl script. What I need is a way to strip query string info and pass it to the script. So our rss feed would have a link like this:
www.site.com/article.html?id=1234&site=mysite
I need a way through the .htaccess file to strip everything after the question mark and pass it to something like:
www.site.com/cgi-bin/article.pl?id=1234&site=mysite
So I'm using the following to detect the mobile browsers and pass them to the script, but it doesn't really work. It passes them to the script but includes the entire original URL after the question mark:
RewriteEngine on RewriteCond %{REQUEST_URI} !^/mobile/.*$ RewriteCond %{HTTP_USER_AGENT} "Windows CE" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "Ericsson" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "Samsung" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "NetFront" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "Palm OS" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "Blazer" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "Elaine" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "^WAP.*$" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "Plucker" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "vodafone" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "iPhone" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "nokia" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "symbian" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "Opera Mini" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "BlackBerry" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "j2me" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "midp" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "htc" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "java" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "sony" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "android" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "AvantGo" [NC] RewriteRule (.*) http://www.site.com/cgi-bin/article.pl?$1
The last line doesn't really work. Any idea if this is doable? I know it's slightly off topic but there are some smart people around here. Thanks.

In reply to Grabbing query string by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.