0

I want to move the uploads folder to a sub-domain. it hosted on another server. there are a lot of guides which is mentioned move the folder to a subdomain which hosted on the same as the main site is. like this

Now, what about a sub-domain on the other server? how can I set FTP's user and password in WordPress?

ps: I found out this plugin. but is there any way to set it without any plugin?

0

Warning! Nothing of the proposed below was tested.

add_filter('upload_dir', 'update_attachment_url');
function update_attachment_url($data)
{
    $data['url'] = str_replace('http://main-domain/', 'http://sub-domain.com', $data['url']);
    $data['baseurl'] = str_replace('http://main-domain/', 'http://sub-domain.com', $data['baseurl']);

    return $data;
}

Code source.

Also you can try to change the values of upload_path and upload_url_path found in the wp_options MySQL table.

Remember to run Search Replace DB to change all published image paths.

  • as I said my problem is all guide just is about a subdomain in the same server. my subdomain is on another server. in your guide how can I set ftp user and pass? – joei Jul 31 '18 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.