2

When I try to reach a file using file_exists("test.xml") it works if its in the same directory, however if I put the file in a directory behind the www and try file_exists("../test.xml") it doesn't find it

I checked to make sure that the www directory is not a shortcut etc but I am suspecting that perhaps nginx is blocking it?

  • http://stackoverflow.com/questions/26520615/php-file-exists-not-working-outside-document-root It's best practice to use an absolute path for the file_exists path. If you use an absolute path (as the first answer in the question I linked suggests) do you still have this issue? – tjfo Mar 28 '17 at 01:35
  • if I do an absolute path like "/var/folder1/www/test.xml" it works for the same folder, but if I put the test.xml outside www and use the same "/var/folder1/test.xml" it doesn't work. I tried that before but I tried it again to answer your question – user7157477 Mar 28 '17 at 01:44
  • Try to edit your web server configuration, insert "php_admin_value open_basedir none" – diavolic Mar 28 '17 at 02:02
  • You will have to specify further, what is web server configuration exactly? and where do I find it? – user7157477 Mar 28 '17 at 02:04
  • @diavolic is referring to a setting in your web server configuration that will allow PHP to access files outside the directory tree (Ctrl + open_basedir in http://php.net/manual/en/ini.core.php). You can do this in an Apache configuration, php.ini or in .htaccess if you have mod_rewrite enabled (but nginx doesn't support mod_rewrite). Sorry I can't be more help, I'm not all that familiar with nginx. http://stackoverflow.com/questions/13291185/open-basedir-how-to-set-for-specific-directory – tjfo Mar 28 '17 at 02:57
  • Thanks Ill check it out, youve been assitive nonetheless – user7157477 Mar 28 '17 at 04:17

1 Answers1

0

My host company told me that I have to symlink allow configuration in apache or .htaccess

heres a link to that https://httpd.apache.org/docs/2.2/mod/core.html

I went to /etc/apache2/conf-availabe/serve-cgi-bin.conf and changed this

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

with

Options +ExecCGI -MultiViews Indexes FollowSymLinks

restarted apache and nginx but still nothing, im getting abit desperate :/