Working with subdomain directories

Good afternoon.
How to write files to a subdomain? For example, the script was launched from the site example.ru, and this script needs to write (delete, etc.) a file located on a subdomain.

$directory = "subdomain.example.ru/cat";
$dir = opendir($directory);

It doesn’t work that way. With the indication of the protocol too.


Answer 1, authority 100%

Domains (and their paths) are in DNS and HTTP. Files are in the file system. These are two different sets (well, or a graph, how to imagine).

How an HTTP address (including scheme, host, port, and path) is converted to an address (path) in the file system depends on the server’s configuration. Find it out for your hoster (it’s different for everyone) and understand what path you need to specify in opendir().

Let’s say I organized the file system on one of my servers like this: (this is just an example)

  • /srv/example.org/htdocs/– for http://example.org/
  • /srv/example.org/ssldocs/bar/– for https://example.org/bar/
  • /srv/foo.example.org/htdocs/baz/– for http://foo.example.org/baz/

But it could be anything, like http://foo.example.org//var/www/org/example/foo/, or generally whatever. Therefore, check with the technical support or system administrator of your hosting provider. Or, if you are hosting yourself (and don’t know where it’s configured), specify what software you use on the server and we’ll try to figure it out from the configuration files.


Answer 2

If you have a Windjws server, then there will be one http directory, and if *nix, there will also be http and a bunch of directories, but the site will be located in http, so you just need to write:

 $directory = "cat";
  $dir = opendir($directory);