今天就提出这个有趣的问题。这就是我所尝试的:
1. Setup a TLD example.com
and a sub domain media.example.com
:
Nginx示例:
server_name example.com;
root /var/www/example.com;
server_name media.example.com;
root /var/www/media.example.com;
确保两个站点都可用,并且Nginx可以写入
/var/www/media.example.com
目录
2. Filter upload_dir
in the example.com
site:
您可以将这些代码行用作插件或直接放入主题:
add_filter(\'upload_dir\', function($uploads)
{
$uploads = array_merge($uploads, [
\'url\' => \'http://media.example.com\',
\'path\' => \'/var/www/media.example.com\',
\'baseurl\' => \'http://media.example.com\',
\'basedir\' => \'/var/www/media.example.com\',
]);
return $uploads;
}, PHP_INT_MAX);
现在,将新媒体文件上载到
example.com
地点它应该像你所期望的那样工作。