Forum Moderators: phranque

Message Too Old, No Replies

Error in <if>-statement

         

Wolli

3:10 pm on Oct 8, 2018 (gmt 0)

5+ Year Member



Hi,
the statements
<if "%{DOCUMENT_ROOT}=~ /usr/">
AddType application/x-httpd-php53 .shtml
FcgidWrapper "/home/httpd/cgi-bin/php53-fcgi-starter.fcgi" .shtml
<FilesMatch "\.shtml$">
SetHandler fcgid-script
</FilesMatch>
</if>

in .htaccess give an syntax-error.
Without the statements
<FilesMatch "\.shtml$">
SetHandler fcgid-script
</FilesMatch>

there is no error.
How do I have to write these statements?

lucy24

5:17 pm on Oct 8, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Isn't that backward? I'm not sure* the two can be nested at all, but if they can be, I tend to think <If> has to go inside <Files>. I don't see anything wrong with the <FilesMatch> itself, so the problem can only be in nesting.


* <If> is a 2.4 construct, while I'm on 2.2, so I'm limited to what I can extract from the docs.

phranque

8:40 pm on Oct 8, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



see the "Nesting of sections" header here:
https://httpd.apache.org/docs/2.4/sections.html#file-and-web

lucy24

10:28 pm on Oct 8, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



On the one hand, <Files> can be used inside <Directory>. On the other hand, <If> can be used inside <Directory>, <Location>, and <Files> sections (but not inside another <If> ).
Ah, there it is. I kinda thought I'd read it somewhere and wasn't just making it up out of the clear blue sky.

(The business about Files and Directory makes sense, because otherwise you wouldn't be able to use Files within htaccess, which obviously we can.)