• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Using " / " for web root problem

I'm not sure what to google or what this is even called...  

*But*, in my local environment (I use MAMP), I can in both my php scripts and js scripts use:

(php)
include "/include/sample.php";

Open in new window


(js)
$.ajax({
                                url: '/js/ajax.php',
                                data: {pc: $('input[name="pc"]').val()},
                                dataType: 'json',
                                type: 'post',
                                success: function(data) {
                                        location.reload();
                                }
                        });

Open in new window


And it "knows" to look in the web root folder (/path/to/www/)

However, once I upload it, it uses "/" as the server root...  I'd like to change that behavior so that it's the same as it is locally...  My server runs CentOS.

I've looked at my php.ini file to see if I could figure something out there, but I'm not sure what to change (if anything...).  Two things possibly worth noting is that:

(1) safe mode is on
(2) open_basedir is set to none

Is there something I can change in my php.ini file, or a relevant setting the apache settings?  I'm not sure what to look for here... Hoping someone can point me in the right direction...
0
n00b0101
Asked:
n00b0101
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Note that 'safe mode' is going away as of PHP 5.4.  http://us3.php.net/manual/en/features.safe-mode.php   'open_basedir' is not affect by 'safe mode'.  http://us3.php.net/manual/en/ini.core.php#ini.open-basedir
0
 
Frederic SuneCEO, IT in MIND inc.Commented:
If your web structure is :
- Root (www)
-- Includes
-- js

You don't need the / at the beginning of your include.
0
 
Dave BaldwinFixer of ProblemsCommented:
The directory problem sounds like 'DocumentRoot' is not set properly.   http://httpd.apache.org/docs/2.2/mod/core.html#documentroot
0
 
Ray PaseurCommented:
I think DaveBaldwin may be right about the DOCUMENT_ROOT issue.  You can use phpinfo(); to print out information about the environmental variables.

You might also want to use the predefined PHP constant DIRECTORY_SEPARATOR instead of hand-coding a slash.  DIRECTORY_SEPARATOR will be context aware and correct no matter whether your script runs on Window, Linux or whatever.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now