ergophobe

msg:4548842 | 10:58 pm on Feb 25, 2013 (gmt 0) |
I haven't looked over the rest of it, but your simplified version won't work. You can have many RewriteCond for a single RewriteRule, but only one RewriteRule for a set of RewriteCond. So you have to simplify more and match (cats|dogs|birds) and replace with $1 in a single rule
|
hottrout

msg:4549489 | 4:08 pm on Feb 27, 2013 (gmt 0) |
I am not using the second version simplified code, I already worked out that it would not work. It is the first example of code that I need help understanding why it will not work. Anyone have any ideas.
|
Andy Langton

msg:4549490 | 4:17 pm on Feb 27, 2013 (gmt 0) |
There's nothing wrong with the code. I'd suggest it's either a caching issue (try checking with an external HTTP header checker) or there is some other rule interfering with this one. Also try using simplifed code as suggested by ergophobe:
# Redirect to remove hex-encoded query string characters from animal folders RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\%3[fF]folder\%3[dD]([^\ ]+)\ HTTP/ RewriteRule ^(cats|dogs|birds)/index\.php http://www.example.com/$1/index.php?folder=%2 [R=301,L]
If dogs redirects but birds doesn't you know it is not a code problem.
|
hottrout

msg:4549527 | 6:15 pm on Feb 27, 2013 (gmt 0) |
OK thank you. I chanegd my code to the following, # Redirect to remove hex-encoded query string characters from animal folders RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\%3[fF]folder\%3[dD]([^\ ]+)\ HTTP/ RewriteRule ^(cats|dogs|birds)/index\.php http://www.example.com/$1/index.php?folder=%2 [R=301,L] It works for dogs and birds but not cats. Any ideas what I should be looking for that would cause the others to not function?
|
Andy Langton

msg:4549533 | 6:21 pm on Feb 27, 2013 (gmt 0) |
Do you have an htaccess file in the cats directory?
|
hottrout

msg:4549538 | 6:33 pm on Feb 27, 2013 (gmt 0) |
Good grief. I have an htaccess in that folder but there are no commands in it. I removed it anyway and guess what it is working. Slaps Head Why did it effect the command? Did it void the previous htaccess requests? Thank you for this, I had been tearing my hair out over this.
|
hottrout

msg:4549539 | 6:39 pm on Feb 27, 2013 (gmt 0) |
BTW, this also fixes another issue I had that made no sense. Thank you so much. I feel like an ass. No matter how much I study regx I still get totally lost sometimes.
|
Andy Langton

msg:4549548 | 7:03 pm on Feb 27, 2013 (gmt 0) |
I believe that unless RewriteOptions inherit is enabled, the second file would override the first, in effect causing there to be no rules to evaluate. But I wouldn't be able to say for sure as I'm no Apache expert by any means. Glad you got it working, regardless! :)
|
hottrout

msg:4549550 | 7:10 pm on Feb 27, 2013 (gmt 0) |
Many thanks Andy, that really saved me from loosing my mind.
|
lucy24

msg:4549639 | 1:31 am on Feb 28, 2013 (gmt 0) |
| Good grief. I have an htaccess in that folder but there are no commands in it. |
| Ooh, good call, Andy. I discovered something similar just recently in a completely unrelated experiment. An empty htaccess file in a subdirectory prevented RewriteRules in the higher directory from working. I detoured here to try to reproduce the problem. After much experiment, I think I nailed it. If an htaccess file contains the RewriteEngine On directive and/or any RewriteRules-- even ones that won't work because the Engine directive is missing-- then RewriteRules in higher-level htaccess files will no longer work for the directory containing the inner RewriteRules. This seems backward, but who's going to argue with Apache? Other permutations have no effect. The ones I tried were: completely empty htaccess; htaccess with content (line breaks) but no actual rules; htaccess containing rules unrelated to mod_rewrite; htaccess in a different subdirectory. Unlike most settings in Apache, the RewriteEngine has to be turned on in each separate htaccess-- and even in Files(Match) envelopes within a single htaccess. :: detour to Apache docs :: Holy ###. I never knew the RewriteOptions directive even existed. I thought you were talking about some newfangled 2.4 stuff, but there it is. There are three options, all of them off by default. | Rules inherited from the parent scope are applied after rules specified in the child scope. |
| Oh, no wonder it's off by default. That means the whole thing has to run backward: you can't start any rewriting until you've arrived at the directory containing the requested file.
|
g1smd

msg:4549645 | 2:03 am on Feb 28, 2013 (gmt 0) |
This stuff has me boggled too -- hence the oft repeated "put all your rules in the root htaccess file and get the rules in the right order".
|
ergophobe

msg:4549647 | 2:25 am on Feb 28, 2013 (gmt 0) |
Lucy24, this surprises me. As long as the rules don't conflict, the inherited rules should get applied (that's my vague understanding - I've never actually used this). For example, if you have ^(.*)$ index.php?q=$1 [L] in a virtual host context, that will match all URLs and so no inherited rules can get applied. | I thought you were talking about some newfangled 2.4 stuff, but there it is. |
| You prompted to do a search of WebmasterWorld and it comes up with surprising frequency: - Interesting note from 2004: [webmasterworld.com...] - And Jim's stock advice for certain problems: "double check your RewriteOptions settings" * [webmasterworld.com...] * [webmasterworld.com...] * [webmasterworld.com...] Even more surprising, given your surprise, is that Lucy24 posted that same quote back in 2011! - [webmasterworld.com...] :-) And many more https://www.google.com/search?num=100&hl=en&q=site%3Awebmasterworld.com+"rewriteoptions+inherit"
|
lucy24

msg:4549718 | 5:36 am on Feb 28, 2013 (gmt 0) |
| Even more surprising, given your surprise, is that Lucy24 posted that same quote back in 2011! |
| This does not surprise me in the least :( I do note that I felt constrained to say "Do as I say, not as I do." I currently have multiple htaccess files but it's as close as you can get to an unimpeachable reason: multiple domains in one userspace. Some directives have to go within individual domains-- or lower-- because they won't work at a higher level. But if I left out the shared htaccess I'd have to maintain three identical IP/UA lists. So I've compromised by saying that any given module can happen only at one level or the other. And, as always, Options +Indexes or -Indexes doesn't count.
|
hottrout

msg:4549770 | 9:11 am on Feb 28, 2013 (gmt 0) |
Thank you Lucy for bringing some further clarity to this. I swear, I have learnt a lot from you guys over the past two years but this was making me question everything I had come to understand. It is great to find out you have not lost your mind. I have removed the other htaccess and think I will just stick to one htaccess in the root. Ironically I only created the subfolder htaccess to test and never really actually used it.
|
ergophobe

msg:4549988 | 10:30 pm on Feb 28, 2013 (gmt 0) |
| This does not surprise me in the least |
| No, I didn't think it would. If you've been around here long enough you've had the experience of googling to see how to fix some problem, landing on a thread here, and realizing that once upon a time you actually answered that same question for someone else.
|
g1smd

msg:4549990 | 10:38 pm on Feb 28, 2013 (gmt 0) |
I'm not alone in that then. That's good to know. :)
|
|