![]() |
Safe way to read file from subdomain <-> maindomain?
Is there way (safe way) to read file from subdomain <-> maindomain?
Real-life scenario ;): I have subdomain (orders.mydomainx.com) and I need to read main function file from maindomain's (mydomainx.com) include folder. Possible? Hope so.. Thanks for all help! |
I'm guess the files are on the same machine so all you would need to know is the path on how to get from the subdomain files to the main domain files. Or the absolute path.
|
Say you have the following file / folder structure:
[Main Folder] + index.html + include.html + image.gif [Sub Folder] + sub.html [Includes Folder] + another.html In sub.html To access include.html you would do the following: PHP Code:
Code:
<img src="../image.gif" alt="bla" />.) mean that you are going a directory back (ie one . would mean you are in the same directory, two . would mean you go back one, three . would be going back two directories).To access another.html in sub.html You would have to go back a directory, then forward another one. Ie: PHP Code:
require(), include() and include_once().Hope this helps Gareth |
Yes if folder structure looks like you show this would be easy but it isn't.. ;)
In this case folder structure looks like following: In my main domain root folder has Code:
httpdocs <- where is main domain filesCode:
/var/www/vhosts/mydomain/httpdocs/Code:
/var/www/vhosts/mydomainname/subdomains/mysubdomainname/httpdocs/And if I try to include from my main domain files Code:
/var/www/vhosts/mydomain.com/httpdocs/inc/function_file.phpCode:
PHP Warning: include() [<a href='function.include'>function.include</a>]: open_basedir restriction in effect. File(/var/www/vhosts/mydomainname/httpdocs/include/include_file.php) is not within the allowed path(s): (/var/www/vhosts/mydomainname/subdomains/mysubdomainname/httpdocs:/tmp) in /var/www/vhosts/mydomainname/subdomains/mysubdomainname/httpdocs/orders.php on line 1Sorry about my first post, I haven't describe my problem good enough.. I have dedicated server, CentOS5 and Plesk 8.3 installed. Thanks for all help! |
You can try turning off
open_basedir in your php.ini file (just comment it out). Before doing that you may want to try chdir right before you include the file and then change the directory back after you've included the file. It may be easier just to turn off open_basedir though. |
| All times are GMT. The time now is 05:38 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0