Re: multiple rewrite rules

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

 



On Mon, Dec 7, 2009 at 7:32 AM, Jeff Shearer <jeff@xxxxxxxxxxxxxxxxxx> wrote:
> Thanks for your excellent explanation.
>
> I have used the book "The Definitive Guide to mod_rewrite" by Rich Bowen.  Do you recommend a different reference?

I don't know about this book. All I know about mod_rewrite I have from
the official docs, and from experimentation.

The documentation is quite clear that you can have multiple
RewriteCond's per RewriteRule, but that a RewriteCond only applies to
one RewriteRule.

I had to cut may answer short, as my train was arriving and I had to
get out :-)

So here is the rest:

I asume that you have references to two CSS files in your HTML pages,
and that you want to give different versions of these files to
different browsers.
Now, since a RewriteCond applies only to one rule, you need to repeat it.
You don't really need the L flag, and if the files are on the same
host, you don't need to add that either. So I asume the following
would work:

RewriteEngine on
 RewriteLog /var/log/httpd-rewrite.log
 RewriteLogLevel 2

 RewriteCond %{HTTP_USER_AGENT}  .Windows.*Firefox\/3.*
 RewriteRule ^/styles/progclean.css    /styles/winff3/progclean.css
 RewriteCond %{HTTP_USER_AGENT}  .Windows.*Firefox\/3.*
 RewriteRule ^/styles/terms.css    /styles/winff3/terms.css

 RewriteCond %{HTTP_USER_AGENT}  .MSIE\ 7.*
 RewriteRule ^/styles/progclean.css    /styles/winie7/progclean.css
 RewriteCond %{HTTP_USER_AGENT}  .MSIE\ 7.*
 RewriteRule ^/styles/terms.css     /styles/winie7/terms.css

 RewriteRule ^/styles/progclean.css     /styles/unsupported/progclean.css
 RewriteRule ^/styles/terms.css     /styles/unsupported/terms.css

I hope this helps,

Krist


-- 
krist.vanbesien@xxxxxxxxx
krist@xxxxxxxxxxxxx
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
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