WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently moving an old website based on some other CMS towards a new server, with WordPress. However, the site ranks good on Google, and I'm have to keep all the link structure, including the ones from images.

So, in the old CMS, the links to images were like this:


Right now, they are like this:


But they have to look like in the first example.

I'm using a lot the /images/... code, so changing that in all .php files and widgets, pages and so on would take hours.

Is there anyway to achieve that with some way to do it, maybe with htaccess?

PS: After searching, I tried a few "Relative image paths" which I found on google... but none of them worked. e.g. i tried this:

function relativePathForUploads($fileInfos)
    global $blog_id;
    $path = get_blog_option($blog_id,'siteurl');

    $fileInfos['url'] = str_replace($path,'',$fileInfos['url']);

    return $fileInfos;
add_filter('wp_handle_upload', 'relativePathForUploads');

and copied it into the functions.php, but it does not do anything.

PPS: I am searching for a way that the printed out path is without the "wp-content/themes/.....".

share|improve this question
up vote 0 down vote accepted

According to me, Copy the "images" folder to your root directory. That will help you. And for future upload, place this code to your wp-config.php

define( 'UPLOADS', ''.'images' );

share|improve this answer
I did the root directory method. Was work and so so clean and stylish, but meh, what ever. Thanks, though! – ShawnWhite Jul 10 '13 at 13:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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