Forum Moderators: phranque
RewriteRule ^(.*).png$ [domain.com...] [L,R=301]
This rule works as advertised, but I need to modify the rule so that it works for my whole site except for directory /admin.
RewriteRule ^[^/admin](.*).png$ [domain.com...] [L,R=301]
I have tried the above, but no luck. Any ideas on what I am doing wrong? I can't seem to figure out how to exclude this one directory from this rule.
Thanks in advance,
P
RewriteCond $1 !admin/
RewriteRule ^([^.]+)\.png$ http://www.example.com/$1.gif [L,R=301]
RewriteCond %{REQUEST_URI} !/admin/
RewriteRule ^([^.]+)\.png$ http://www.example.com/$1.gif [L,R=301]
Second "[]" defines a list of characters and not a word, so "[^word]" means, "NOT w, o, r, or d". It does not mean "NOT "word". Use the "!(word)" construct in a separate RewriteCond instead.
Note also that I changed your "(.*)" pattern to "([^.]+)", which is a much more efficient pattern, and escaped the literal period in the pattern -- otherwise, the unescaped "." means "any single character."
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim