September 4th, 2013, 04:02 AM
How to write rewrite rule for files included with include_once / require_once
I am getting problem of loading file which is included into the page with include_once() / require_once() methods. I am not sure from which entry point its giving the problem, but logging errors in erro log file. Locally its working fine, no issue of paths but giving issue while a some unknow entry points which access the application.
I am using nginx+php5-fpm+ubuntu as an environment.
To overcome this issue, I am thinking to write a rewrite / alias for the inclusion of the missing file. (for example, _autoload.php). Can you tell me how to do this specially for missing files or incorrect referenced files using include_once() / require_once() and it should be in working mode.
Thanks in advance!
September 4th, 2013, 04:06 AM
If there are errors then they will say where the file was being included from. If the errors say it's in "main" or "unknown" then it's probably the auto_prepend_file setting or... I think there's another thing that would act like that, can't remember it right now.
September 4th, 2013, 04:43 AM
Thanks requinix for quick reply. But yes... its giving path reference issue, but in normal site access its not giving the problem, all path references are correct.
and that's why trying forcefully to redirect to specified file thru nginx reqrite url but this shoudl for thes inclusion methods.
September 4th, 2013, 05:03 AM
How about posting the actual error message?
September 4th, 2013, 08:58 AM
NgnixErrorLog AppServer 2013/09/03 09:05:48 [error] 2747#0: *35201 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'Settings' not found in /<path>/cache_file.php on line 5" while reading response header from upstream, client: <IP>, server: server.name, request: "POST /bib/Operations.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "serve.name", referrer: "server.name/cite.php?add=ABC"
wherein Class 'Settings' is defined in one autoload.php file which is included in cache_file.php using include_once() and its reference <path> is correct in the file. Working fine locally and on the actual server as well, but giving problem while accessing the site through some entry point.
**For security reason, added dummy server and file names.
September 4th, 2013, 01:21 PM
Make sure you have your error_reporting set to include notices and warnings: either the inclue_once() isn't even executing and there's something fundamentally wrong with your setup, or it is and there's some problem you're not being told of (likely that it can't find the file).