Make WordPress upload directory outside wordpress root with custom url

I want to change the upload directory for WordPress from project.dev/wp-content/uploads to cdn.project.dev

Where subdomain cdn has DocumentRoot:
HostPath/project.dev/cdn while WordPress is located at HostPath/project.dev/public_html

Read More

Any help is much appreciated.

Related posts

2 comments

  1. if you need to change default media upload location,you need to edit the wp-config.php file located in the root directory of your WordPress installation. If you want upload directory to be wp-content/files then you will need to place the following code in wp-config.php

    define( 'UPLOADS', 'wp-content/'.'files' ); 
    

    If you want the upload directory to be outside wp-content, like project.dev/cdn then you need to set upload path in wp-config.php like this:

    define( 'UPLOADS','project.dev/cdn' ); 
    

    For exstining images:-

    Copy all the exstining images of uploads folder to new folder which has set in the wp-config.php file.

    The above information is only to Change the Default Media Upload Location.

    For Details visit :WordPress Codex

  2. Open your wp-config.php file, locoed at the root of your WordPress installation, and add the following snippet:

    define('UPLOADS', 'project.dev/cdn');
    

    Make sure you add this code before the line:

    require_once(ABSPATH.’wp-settings.php’);
    

Comments are closed.