Title: Modify path for CNAME
Last modified: August 21, 2016

---

# Modify path for CNAME

 *  Resolved [LuxDelux](https://wordpress.org/support/users/luxdelux/)
 * (@luxdelux)
 * [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/)
 * Could you perhaps implement a simple field on the settings page where we can 
   enter a custom files path in case we’re using a CNAME?
 * Facebook has problems reading post images if the regular rackspace path is used
   so I made a simple CNAME eg. images.example.com
 * Or please there me where I could change this in the php files manually so my 
   files are read from this new CNAME?
 * Cheers
 * [https://wordpress.org/plugins/rackspace-cloud-files-cdn/](https://wordpress.org/plugins/rackspace-cloud-files-cdn/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [LuxDelux](https://wordpress.org/support/users/luxdelux/)
 * (@luxdelux)
 * [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/#post-4934454)
 * Ok I figured out how to do it manually for those interested:
 * Open
 *     ```
       rackspace-cloud-files-cdn/lib/functions.php
       ```
   
 * On line 217 change
 *     ```
       $_SESSION['cdn_url']
       ```
   
 * to
 *     ```
       'http://images.example.com'
       ```
   
 * or whatever name you chose.
 * My suggestion is to make this an option so we can easily change through the admin
   interface.
 * Cheers
 *  Plugin Author [paypromedia](https://wordpress.org/support/users/paypromedia/)
 * (@paypromedia)
 * [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/#post-4934748)
 * I made this change. Please let me know if this resolves your issue.
 *  Thread Starter [LuxDelux](https://wordpress.org/support/users/luxdelux/)
 * (@luxdelux)
 * [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/#post-4934749)
 * Doesn’t seem to work, I tried entering with
 * `http` and without, images still point to default url
 * How it works for me:
 *     ```
       if (current_filter() == 'wp_get_attachment_url') {
       		if (file_exists(str_replace($upload_data['baseurl'], $upload_data['basedir'], $attachment)) !== false) {
       			return $attachment;
       		} else {
       			return str_replace($upload_data['baseurl'], 'http://images.tapebrain.com', $attachment);
       		}
       	} else {
       		preg_match_all('/\"(http|https).*?\/wp\-content\/.*?\/\d{4}+\/\d{2}+\/.*?\"/i', $attachment, $attachments);
   
       		foreach ($attachments[0] as $cur_attachment) {
       			// If local file does not exist, replace local URL with CDN URL
       			$cur_attachment = trim($cur_attachment, '"');
       			if (file_exists(str_replace($upload_data['baseurl'], $upload_data['basedir'], $cur_attachment)) === false) {
       				$new_attachment = str_replace($upload_data['baseurl'], 'http://images.tapebrain.com', $cur_attachment);
       				$attachment = str_replace($cur_attachment, $new_attachment, $attachment);
       			}
       		}
   
       		return $attachment;
       	}
       ```
   
 * not sure if the second one is needed though
 *  Plugin Author [paypromedia](https://wordpress.org/support/users/paypromedia/)
 * (@paypromedia)
 * [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/#post-4934757)
 * Since the CDN URL is using a session variable, I had to make it update in the
   save settings function, I wasn’t doing that. Please update and let me know if
   this has resolved the issue.
 *  Thread Starter [LuxDelux](https://wordpress.org/support/users/luxdelux/)
 * (@luxdelux)
 * [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/#post-4934761)
 * Seems to work, thanks for the update 🙂
 *  Plugin Author [paypromedia](https://wordpress.org/support/users/paypromedia/)
 * (@paypromedia)
 * [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/#post-4934773)
 * Great! Thanks for letting us know.
 *  Plugin Author [paypromedia](https://wordpress.org/support/users/paypromedia/)
 * (@paypromedia)
 * [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/#post-4934774)
 * This request has been resolved. If you are willing, please rate and review the
   plugin.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Modify path for CNAME’ is closed to new replies.

 * ![](https://ps.w.org/rackspace-cloud-files-cdn/assets/icon-256x256.jpg?rev=1001447)
 * [Rackspace CDN](https://wordpress.org/plugins/rackspace-cloud-files-cdn/)
 * [Support Threads](https://wordpress.org/support/plugin/rackspace-cloud-files-cdn/)
 * [Active Topics](https://wordpress.org/support/plugin/rackspace-cloud-files-cdn/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/rackspace-cloud-files-cdn/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/rackspace-cloud-files-cdn/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [paypromedia](https://wordpress.org/support/users/paypromedia/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/modify-path-for-cname/#post-4934774)
 * Status: resolved