0

Ok, so I read several questions and answers and none of them is working for me, so here it goes:

Firstly,

  1. My webhost doesn't allow: $_SERVER['DOCUMENT_ROOT']
  2. All files are supposed to be uploaded under a folder called public_html - so it's http://mysite.com/pulic_html/myfolder/myfile.php

Now my issue is -

I have a master file - init.php under http://mysite.com/pulic_html/ and I have error files under - http://mysite.com/pulic_html/pages/error/403.php

How to I include init.php in 403.php.

  • edit * Please note, public_html is not a part of the URL. I have shown it here to just show where my files actually exist.

These fail:

init.php
/init.php
./init.php
../init.php

4
  • init.php is two folders up from 403.php, so you'll need to go up two folders: ../../init.php. Commented Jun 21, 2013 at 16:22
  • You are really sure that ''public_html` should be part of the url? I doubt that: usually that is just the name of the "web documents folder" inside a users home directory on a unix like system. But the http request to access documents stored there usually looks different... Commented Jun 21, 2013 at 16:22
  • public_html is not a part of the URL. I put it in there to show where my files actually exist. The files will actually be loaded as mysite.com/pages/error/403.php Commented Jun 21, 2013 at 16:25
  • Thanks @Vulcan. That did do the trick! Commented Jun 21, 2013 at 16:39

2 Answers 2

2

Change webhost or switch to plan where PHP has a sensible configuration.

public_html should never be enforced as part of the external URL.

$_SERVER['DOCUMENT_ROOT'] should be allowed, it's a read-only variable.

Sign up to request clarification or add additional context in comments.

5 Comments

I know. That'd come later. But as of now, since I just need a free webhost, and frankly, these guys have a good service and support team, so will stick to them for development purposes.
If you're just doing development and you're not particularly picky, install wampserver on your own (Windows) machine and develop on that. It's one of those packages where you just click 'install' and it sets defaults that aren't too bad.
Yes, I'm using XAMPP. The development so far is going fine and localhost is working great. I'm just trying to put up the placeholder page on my site to start gathering emails for when I actually take the site online.
good service would incldue NOT enforcing arbitrary/stupid sub-directories in your public-facing URL-space. They could require you to put http-related files into a public_html sub directory, but enforcing that directory being part of the URLs is just outright stupid.
I'm sorry for the confusion. That is just a directory and not a part of the url. I put it in the question to give an idea about where my files actually exist. I'll edit the question.
0

use this code for include init.php

../../init.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.