https://bz.apache.org/bugzilla/show_bug.cgi?id=58789

--- Comment #40 from gilpe...@gmail.com ---
@Luca

You are awesome, now that section is great! I totally agree with what you said:
those apache directives (Directory, Filesmatch...) are used to "filter" modules
use cases. Sometimes we want some modules to act only when certain Directories
conditions are applied. You are correct. But sometimes not. Check this example:



RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^.*$ https://%{HTTP_HOST}?redirected1 [R=301,NE,L]

<If "%{REQUEST_URI} =~ m#^$#">

    RewriteRule ^.*$ https://%{HTTP_HOST}?redirected2 [R=301,NE,L]

</If>


In the case above, if the user requests "www.xxx.com" I would like it first to
be redirected to "https://%{HTTP_HOST}?redirected1"; and after that to
"https://%{HTTP_HOST}?redirected2";.

But the "bug" that I reported in this thread makes it differente: Apache will
actually first process "https://%{HTTP_HOST}?redirected2"; and after that
"https://%{HTTP_HOST}?redirected1";.

To overcome this "bug" I have to use a "hack" (I know this word is not great
here, but that's how I name something that I have to do in order to correct
some unexpected or bad programmed feature in a language):


<If "%{REQUEST_URI} =~ m#^.*$#">

RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^.*$ https://%{HTTP_HOST}?redirected1 [R=301,NE,L]

</If>

<If "%{REQUEST_URI} =~ m#^$#">

    RewriteRule ^.*$ https://%{HTTP_HOST}?redirected2 [R=301,NE,L]

</If>


You see, I just had to create '<If "%{REQUEST_URI} =~ m#^.*$#">' to try to
overcome this problem. I know, I really know, I could program this code in a
much better and faster way, I know it. It's only an example of how apache's
confusing processing rules order is not intuitive and may cause really
unexpected results. This "bug" took me at least 8 months to try to get it
understood/solved. I lived with this "Header" "bug" for a long time but since
it was not too critical I didnt care, but latelly I started using a CDN and I
really had to know how to fix this problem.



By the way, the section "Relationship between modules and configuration
sections" is a m a z i n g! It will surelly clarify lots of misconception about
apache rules order :)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscr...@httpd.apache.org
For additional commands, e-mail: docs-h...@httpd.apache.org

Reply via email to