Secure WordPress by renaming wp-content folder

Tutorials 0 lượt xem

How to secure WordPress by renaming wp-content folder?

As you know, in a website using  WordPress source code  , all image files, stylesheets, themes or plugins by default are located in the  wp-content folder .

What if you rename this folder to something else? Is your wordpress website still working? The answer is that it will still work properly if you follow my instructions below.

Instructions for renaming wp-content folder

Step 1: Go to the folder containing the web and rename the folder wp-content folder to a new name, for example I will change the new name to

Step 2: Configure the file wp-config.php

Open the file wp-config.php find the line

require_once(ABSPATH . 'wp-settings.php');<div><span>1</span></div>

Insert the code below above it.

define <span class="token punctuation">(</span><span class="token string">'WP_CONTENT_FOLDERNAME'</span><span class="token punctuation">,</span> <span class="token string">'hocwordpress'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
define <span class="token punctuation">(</span><span class="token string">'WP_CONTENT_DIR'</span><span class="token punctuation">,</span> <span class="token constant">ABSPATH</span> <span class="token punctuation">.</span> <span class="token constant">WP_CONTENT_FOLDERNAME</span><span class="token punctuation">)</span> <span class="token punctuation">;</span><div>
<span>1</span><span>2</span>
</div>

Thumbnail of the theme in the theme folder is not displayed, which means that the theme displayed outside the main website is also not displayed due to the lack of stylesheets, images, etc.

Fix it by, inserting these 2 lines of code into the next position of the above 2 lines of code.

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/'); define('WP_CONTENT_URL', WP_SITEURL . WP_CONTENT_FOLDERNAME);<div><span>1</span></div>

With just 4 simple lines of code above, you have renamed the wp-content folder to a new name. After the renaming is done,
all uploaded files are uploaded to the folder with the path being the name of the new folder.

Epilogue

So I have shared how to secure WordPress by renaming the wp-content folder.

If you find it interesting, you can follow the  wordpress tips section  to know more new knowledge.

Follow fanpage to receive the latest posts:  Group

Wish you have interesting and interesting knowledge about wordpress!

Bài viết liên quan