You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Benjamin Smith <ye...@gmail.com> on 2018/06/08 23:47:58 UTC

[users@httpd] Oddity using FallbackResource in PHP development

Apache is returning 404 when an invalid PHP script is called, even though
FallbackResource is configured and working fine for invalid scripts without
the .php extension.

Said another way, when I use FallbackResource, with a PHP file as the
target, it works fine only when I don't reference an invalid PHP file. When
I do, it doesn't work. I've spent hours poring over documentation and
pounding on Google to no avail.


### Configuration ###
CentOS 6/64, stock install, all updates applied.
Apache 2.4.6
php 5.4.16

Document root has a single PHP file "route.php" in it, with one line:
<?php die("I was found");

/etc/httpd/conf.d/site.conf contains:
FallbackResource /route.php


### Problem demonstrated ###
When I go to
http://site.com/route.php
I see "I was found".

When I go to
http://site.com/invalid
I see "I was found"

When I go to
http://site.com/invalid.php
I see 404 "Not Found The requested URL /invalid.php was not found on this
server."


Wheat do I need to do to get FallbackResource to work for URLs that look
like a PHP script?

Thanks

Re: [users@httpd] Oddity using FallbackResource in PHP development

Posted by Benjamin Smith <ye...@gmail.com>.
That was it, thanks!

Now, in my /etc/httpd/conf.d/site.conf I have:
       <Directory "/path/to/site.com">
               <FilesMatch \.php$>
                       SetHandler None
               </FilesMatch>
               <FilesMatch route\.php$>
                       SetHandler application/x-httpd-php
               </FilesMatch>
       # blah blah other stuff
       </Directory

Now, it routes ALL calls through route.php. Thanks!

On Fri, Jun 8, 2018 at 4:51 PM, Daniel Gruno <hu...@apache.org> wrote:

> Do you have a handler configured for .php that might interfere here? If
> you have something like mod_php or fpm handling .php extensions, that may
> take over from the generic file handler (which is what FallbackResource
> works for) and try to serve it instead.
>
> A solution, if this is the case, would be to only assign that handler to
> route.php, and not .php in general.
>
>
> On 06/08/2018 06:47 PM, Benjamin Smith wrote:
>
>> Apache is returning 404 when an invalid PHP script is called, even
>> though  FallbackResource is configured and working fine for invalid scripts
>> without the .php extension.
>>
>> Said another way, when I use FallbackResource, with a PHP file as the
>> target, it works fine only when I don't reference an invalid PHP file. When
>> I do, it doesn't work. I've spent hours poring over documentation and
>> pounding on Google to no avail.
>>
>>
>> ### Configuration ###
>> CentOS 6/64, stock install, all updates applied.
>> Apache 2.4.6
>> php 5.4.16
>>
>> Document root has a single PHP file "route.php" in it, with one line:
>> <?php die("I was found");
>>
>> /etc/httpd/conf.d/site.conf contains:
>> FallbackResource /route.php
>>
>>
>> ### Problem demonstrated ###
>> When I go to
>> http://site.com/route.php
>> I see "I was found".
>>
>> When I go to
>> http://site.com/invalid
>> I see "I was found"
>>
>> When I go to
>> http://site.com/invalid.php
>> I see 404 "Not Found The requested URL /invalid.php was not found on this
>> server."
>>
>>
>> Wheat do I need to do to get FallbackResource to work for URLs that look
>> like a PHP script?
>>
>> Thanks
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Oddity using FallbackResource in PHP development

Posted by Daniel Gruno <hu...@apache.org>.
Do you have a handler configured for .php that might interfere here? If 
you have something like mod_php or fpm handling .php extensions, that 
may take over from the generic file handler (which is what 
FallbackResource works for) and try to serve it instead.

A solution, if this is the case, would be to only assign that handler to 
route.php, and not .php in general.

On 06/08/2018 06:47 PM, Benjamin Smith wrote:
> Apache is returning 404 when an invalid PHP script is called, even 
> though  FallbackResource is configured and working fine for invalid 
> scripts without the .php extension.
> 
> Said another way, when I use FallbackResource, with a PHP file as the 
> target, it works fine only when I don't reference an invalid PHP file. 
> When I do, it doesn't work. I've spent hours poring over documentation 
> and pounding on Google to no avail.
> 
> 
> ### Configuration ###
> CentOS 6/64, stock install, all updates applied.
> Apache 2.4.6
> php 5.4.16
> 
> Document root has a single PHP file "route.php" in it, with one line:
> <?php die("I was found");
> 
> /etc/httpd/conf.d/site.conf contains:
> FallbackResource /route.php
> 
> 
> ### Problem demonstrated ###
> When I go to
> http://site.com/route.php
> I see "I was found".
> 
> When I go to
> http://site.com/invalid
> I see "I was found"
> 
> When I go to
> http://site.com/invalid.php
> I see 404 "Not Found The requested URL /invalid.php was not found on 
> this server."
> 
> 
> Wheat do I need to do to get FallbackResource to work for URLs that look 
> like a PHP script?
> 
> Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org