• Resolved MarionFW

    (@marionfw)


    Hi,
    I had a crash of my site and reinstalled it. Everything seems to work fine, but for one thing: I get loads of 404-errors. They all refer to the folder wngs_content: in the old site (that crashed) I earlier changed the standard foldername wp_content into this new name.

    In the new site, I prefer using the standard wp_content. But now I’m getting all these errors.

    I’m not sure if I should ask my question on this support forum, but as the change of the content-folder was originally made through iThemes Security, I hope someone may advise me what to do best.

    https://wordpress.org/plugins/better-wp-security/

Viewing 4 replies - 1 through 4 (of 4 total)
  • At the time you used the iTSec plugin Advanced Change Content Directory feature the only 2 changes made by the plugin were:

    The following 3 lines were added to the top of the wp-config.php file:

    //Do not delete these. Doing so WILL break your site.
    define( 'WP_CONTENT_URL', 'http://www.yourdomain.com/wngs_content/' );
    define( 'WP_CONTENT_DIR', 'wngs_content' );

    And the wp-content folder was renamed to the new folder name as specified.

    Once the feature is used\applied it does not provide you with an option to undo it …

    To undo the iTSec plugin feature you would have to manually undo the above 2 changes.

    However there is a database complication. The content of your site stored in the database will most of the times contain hard coded content paths … (these cause your 404 pages).

    If you just started the website the number of hard coded content paths are probably manageable. But if the website is eg 1 year old it will probably contain lots of hard coded content paths …

    This is why the iTSec plugin Advanced Change Content Directory feature warns you to only use the feature in a NEW (clean) WordPress site …

    So how do you replace all those old content paths with new ones in the database ? (Well actually in your case replace all new content paths with the old (default) one).

    2 possible options (there may be more):

    – If you used a database backup to restore your site, perform a search (old wp-content) and replace (new wp-content) on the database backup file before using it to restore the database.
    Note this is only an option for a text based (not binary) backup file.

    – Once the database is already restored, simply use a tool that performs the search and replace on the database.
    A quick search on the internet produced this tool:
    https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
    But there may be others out there. Using such tools is at your own risk.

    So you have 2 options.

    Easy way out is to add the 3 earlier mentioned lines at the top of the wp-config.php file and rename the wp-content folder to wngs_content. This way things are as they were in the old site.

    The other more complicated option is to search and replace either in the backup file or directly on the database.

    dwinden

    Thread Starter MarionFW

    (@marionfw)

    Hi dwinden,
    thanks so much for this explanation. I suppose I’d better go for the easy way, and change things back to what they were before, to avoid any risk of a broken site by changing the datase.

    Just to be sure one more question about the third line
    ‘define( ‘WP_CONTENT_DIR’, ‘wngs_content’ )’

    Do I understand correctly that just the name of the content folder is enough? In the old wp-config.php file, there is a whole path:
    ‘/var/www/vhosts/xx/xxxxx/webspace/siteapps/WordPress-xxxxx/htdocs/wngs-content’ (I changed some digits into xxx)

    I’m not sure if this is just because the old site was installed thruough a webapp. The new site is a fresh, regular WordPress install.

    My apologies for the error.
    Indeed the third line needs a full path.
    This has nothing to do with how WordPress was installed.

    If the provided info helps you resolve the issue please mark this topic as ‘resolved’.

    dwinden

    Thread Starter MarionFW

    (@marionfw)

    I’m not sure why, but the easy way did not work out. As my site is not too large, I choose to replace old content paths.
    It seems to work fine now, so topic is closed.

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

The topic ‘404 errors and changing name content folder’ is closed to new replies.