15th September 2012 Mario Gheghici

How to change the installation folder of WordPress – 3 easy ways and situations

Wp-admin in a diferent folder – change installation directory for wordpress

There are many tutorials about this on the Internet. What I’m saying here is not new, I just hope to be more explicit, to make it easier for you to have WordPress’s wp-admin in a diferent directory.

First of all, there are 3 different situations:
1. A new installation
2. The wp is installed in root, but for security reasons you want to change the directory, but keep the target of the blog to www.name.com
3. This is a bit complex, it’s about changing wordpress directory after you got a lot of content – we need to make some changes in mysql too, but I will explain this to you later on.

Ok now. So, for the first two situations, the change of the directory it’s made in just a few minutes, and the steps are quite simple.

1. A new installation:
You’ve just downloaded the wp in a zip file. WordPress it’s always in a folder named “wordpress”. If you use cpanel to upload the files, then upload the zip file, then extract it. Change the name of the extracted directory to whatever you want. If you use ftp to upload it, you can change the name before or after the upload. Don’t keep it “wordpress” for security reasons. I will explain that to you in another post. Let’s say the name of the directory is now “alabama”.
Install wordpress the normal way. Now, the blog will point to name.com/alabama. Login in wp-admin, go to Settings -> General. There, you’ll see WordPress Address (URL) and Site Address (URL). Both will have www.name.com/alabama. Change the Site Address (URL) to www.name.com.
Now, go back to ftp, or to CPanel, and move index.php and .htaccess to the root, insteead of keeping those two files in “alabama”folder. Open index.php in a text editor. Notepad is just fine, or you can use the online editor on CPanel.
Now make a small change: <?php require(‘./wp-blog-header.php’); ?> becomes <?php require(‘./alabama/wp-blog-header.php’); ?>.
Save (upload) the file, and that’s all.

2. So, you’ve installed everything, the blog is sparkling, but you want to have a different installation directory. Quite easy.

First, login to Dashboard, go to Settings – > General. There, you’ll see WordPress Address (URL) and Site Address (URL). Both will have www.name.com. Change WordPress Address (URL) to www.name.com/alabama (just an example, you can change any name for the directory).
Move all the files, excluding index.php and .htaccess in the new folder “alabama”. Open index.php in a text editor, and make a small change: <?php require(‘./wp-blog-header.php’); ?> becomes <?php require(‘./alabama/wp-blog-header.php’); ?>.
Save (upload) the file, and that’s all.

3. Every time you make a change on WordPress, first do a backup. Not only in this situation.
Now, let’s say that you have a blog with lots of posts, with images, and you want to change the installation folder. First, go to your Cpanel, or domains, if you use GoDaddy, and log in to phpMyAdmin to administrate the database. Click on Export tab and chose “Custom – display all possible options”. In Object creation options -> Add statements, make sure that all the options are checked. “Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement” is not usually checked by default, but I recomand you to check it.
On Format chose sql, and click Go.
Save the sql file in your computer. Depending on the number of posts, the sql file can be big. Now, open the sql file with Notepad. Ctrl + H, to replace all.
Find: name.com/net/wp-content/
Replace all: name.com/alabama/ net/wp-content/
Now, do the same steps as on previous situation, moving the files to “alabama” folder. You will see that the website works, but the images are not shown. That’s because the images were in name.com/net/wp-content/uploads/year/month, instead of name.com/alabama/net/wp-content/uploads/year/month. That’s why we made these changes on the sql file.
REMEMBER: when you alter the sql file, make sure that you have a copy of the original one.
Now, we have two choices: What I usually do, I just import to mySQL the new sql file. That’s why we’ve chosen “Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement”. If everything it’s ok, then we’re done. If something goes wrong (I don’t know, maybe a plugin) then import the old sql file, and try to see what was wrong. You can try to change only the wp-posts table.

The second option: Don’t alter the original database, but create a new one. Import the modified sql file in the new database. Then open wp-config.php and change the MySQL settings:
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘database-name’);

/** MySQL database username */
define(‘DB_USER’, ‘username’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘pass’);
Save and upload the file. That should work too. Good luck!


About the Author

Mario Gheghici Mario Gheghici has over 15 years' experience in media and advertising. Throughout his career he has been a journalist, a PR expert, advertising guru, and now he is widely known as a social media, online marketing, web development and SEO consultant. | Follow @mariusdigital | Follow on Google+ | Connect on LinkedIn |

Comment (1)

  1. I know this if offf topic but I’m looking into starting my own blog and was curious what all is needed to get setup?
    I’m assuming having a blog like yours would clst
    a pretty penny? I’m not very web savvy so I’m not 100% sure.
    Any recommendations or advice would be greatly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get In Touch With Us!

Dream big! With us you can!