#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    3
    Rep Power
    0

    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!

    -Pritam
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,141
    Rep Power
    9398
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    3
    Rep Power
    0
    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.
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,141
    Rep Power
    9398
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    3
    Rep Power
    0
    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.
  10. #6
  11. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,141
    Rep Power
    9398
    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).

IMN logo majestic logo threadwatch logo seochat tools logo