The Codex article on Giving WordPress its Own Directory is very helpful.
However, when I made the decision to do this after the site had been running for awhile, I found there was one more step that I needed to perform.
This may be obvious, but just in case it’ll be helpful to anyone, here’s what I found.
Let’s assume that any images, files, etc. that were uploaded while the site has been running were uploaded to the default location:
[This can be changed in Options > Miscellaneous.]
After the move as described in the Codex article, the addresses for those items will be, for instance,
but any page that references that uploaded file will still think that its address is
Here are a few thoughts on resolving this:
1. If it’s just a few files, it may be easiest to use phpMyAdmin and edit the wp_post table: for each row where post_type=”attachment” change the guid field to be the correct address.
2. If that’s too much hassle, then
a. In Options > Miscellaneous, set the upload folder to
b. In the file system create a directory wp-content at the same level as the directory wordpress and move wordpress/wp-content/uploads to wp-content/uploads.
3. #1 is awkward and #2 can be confusing since it results in two wp-content directories. To avoid this problem in the future, I’ll probably install with the upload directory set to
i.e. a directory at the same level as the one containing the WordPress core files. That’ll have the side effect of insulating those files from any WordPress upgrades — leaving the wp-content directory with just plugins and themes (which I can maintain much more easily than the uploaded files).
Does anyone see any arguments against #3? Other comments?
- The topic ‘How to move attachments when moving an existing install to its own directory’ is closed to new replies.