Re: [users@httpd] mod_rewrite question, escaping quantifiers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tony VanScoy wrote:
I want to redirect certain requests to a pdf depending on a get
variable. nothing new, but I just can't get it to work. So I started
with the basics but just redirecting a certain page to a pdf, which
works.

RewriteRule ^/test\.php$ /pdf/somefile.pdf$ [R,T=application/pdf]

Which works fine. But, since I want to send different pdfs depending
on an ID,  I need to handle urls like this one...

/test.php?fileId=12

.. which in turn should redirect to ...

/pdf/pdfnumber12.pdf

... so i wrote this rule...

RewriteRule ^/test\.php\?fileId\=12$ /pdf/pdfnumber12.pdf [R,T=application/pdf]

.. which does not work. But even when I simplify the regex to just ...


I believe RewriteRule only looks at the URL, not the query string following the "?".

But you can use a RewriteCond to look at the query string. Something like this ought to work:

RewriteCond ${QUERY_STRING} ="fileId=12"
ReWriteRule ^/test\.php$ /pdf/somefile.pdf$ [L]

John



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux