Change directory Ghost

If you need to change the name of the root directory of your ghost installation, there are a couple of steps you'll need to take to ensure everything functions as expected. Should you want to change the domain name the same procedure will apply barring Step 4.

You will need to change a couple of files: cron.php, config.js, and .htaccess

Step 1:

To get started edit cron.php:

""

The part highlighted in red is where you will change the directory name. We changed ours from blog to tech.

Step 2:

Next, edit config.js:

""

Surprise surprise, change the part highlighted in red to the new url.

Step 3:

The next file to edit is the .htaccess file:

""

Simply change the URL and directory name for the part highlighted in red.

If you can't see the .htaccess file and you're using the default file manager in cPanel you'll have to click on Settings on the top right and then:

Tick Show Hidden Files (dotfiles)

""

Step 4:

Now that all the necessary files have been edited, a few columns in the database need to be updated. These columns are markdown, html, and image in the posts table. It is necessary to update these columns to ensure that any post images reference the correct directory. You'll need to run the following 3 commands in phpMyAdmin:

UPDATE posts SET markdown = REPLACE(markdown, '/OLD_DIR_NAME/content', '/NEW_DIR_NAME/content') WHERE markdown LIKE '%/OLD_DIR_NAME/content%';

UPDATE posts SET html = REPLACE(html, '/OLD_DIR_NAME/content', '/NEW_DIR_NAME/content') WHERE html LIKE '%/OLD_DIR_NAME/content%';

UPDATE posts SET image = REPLACE(image, '/OLD_DIR_NAME/content', '/NEW_DIR_NAME/content') WHERE image LIKE '%/OLD_DIR_NAME/content%';