C.Sheep C.Sheep - 5 months ago 8
PHP Question

Require() file stopped working after update to php56

After updating to PHP version 5.6.23,

require()
stopped working for files that are rewritten in
.htaccess
. The page works fine when requiring the actual file
Qb0XTST.php
.

I did try updating composer.

Error message:


Fatal error: require(): Failed opening required 'staffHelp' (include_path='.:/usr/local/php56/pear') in /home/mittensl/public_html/Staff-Lounge.php on line 3


Rewrite engine works for every other file (I haven't discovered any errors yet):

RewriteEngine On
RewriteRule ^staffHelp/?$ Qb0XTST.php [NC,L]

Answer

require (and include) has nothing to do with Apache's mod_rewrite. It looks for the path given and not for some rewritten URL.

The error message confirms this. require('staffHelp'); looks for a file staffHelp, and does not involve Apache's rewrite rules in any way.

Apache's rewrite rules will be applied only, when there's an HTTP request coming in, which doesn't happen, when PHP requires or includes a file.