Jump to content

run another php file, in another folder on the linux server


Recommended Posts



I'm trying to have my index.php to open/run another test.php file.

I'm having my own server that I play with, that I run Ubuntu on.


So the index.php are located at /var/www/ directory, but I want to run a file that are located at /testing/test.php


The final test.php is file for showing pictures, and I don't want to out all the pictures under the /var/www/ location.  It's alot  of photos.

I don't know much about php but I have been trying this:



header("Location: /var/www/testing/test.php");

    //These below are desperat old tries.

//header("Location: ./testing/test.php");

//header("Location: ../testing/test.php");

//$handle = fopen("/privat/Web_pictures/test.php", "r");


// header("Location: ./test.php");  //This one actually works, but I'm still in the wrong folder (/var/www/)

echo "test "; // NN4 requires that we output something...




Thankful for help!  :confused:


Link to comment
Share on other sites

the Location: header is a redirect for the browser, it doesn't execute anything until the user's client (browser) follows the redirect, but it will be unable to follow the redirect because the destination is outside of the public directory.


what you CAN DO is include that file



Link to comment
Share on other sites

Tanks for the help!  :D


That took me one step further.

But now I got stuck on original file (from SFPG).

It's still showing the pictures from the /var/www/ directory. It's all has to do with the top lines (at least I think so). so I copied my tries in here.



                Single File PHP Gallery 4.1.0 (SFPG)





        //      ----------- CONFIGURATION START ------------


        define("GALLERY_ROOT", "../../testing/");  //My try after your comments above (with this the browser will just load and load the page...)

//      define("GALLERY_ROOT", "/testing/");    //Thought this would work

//      define("GALLERY_ROOT", "/testing/");

//      define("DATA_ROOT", "./_sfpg_data/");

        define("DATA_ROOT", "../..//testing/");


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.