Friday, April 3, 2020

Power up the WordPress .htaccess file with these tricks

The .htaccess file is extremely important for your website because it connects the website with the server and allows you to configure some processes locally. You can access it via FTP in the root folder, it’s a hidden file that must be installed or modified carefully because you can damage your website if you don’t do that correctly.

The .htaccess file is a text file that can be created and modified by a text editor. Its creation varies according to the server, some allow creating and editing them directly on a server and others must be created separately and then uploaded to the server.

Tips to configure the .htaccess file

Redirect your content to FeedBurner

With the following code you will redirect your feed to the Feedburner management tool.

Block one or more IP addresses

With this trick you can block the IP you want if a user has maintained an inappropriate behavior on your website. Enter this code in the .htaccess file by changing the IPs with which you want to block.

Redirect name and day of permalinks to /% category% /% postname% /

When you create the file locally in the Windows Notepad you must check the option “all files” so that it is not saved with the .txt extension and then you should only upload it to the destination directory as follows:

  1. Go to Settings.
  2. Enter Permalinks.
  3. Click on Customize
  4. Fill in the field with

To redirect all backlinks to the new permalinks structure with the same link structure that you had, you must edit the .htaccess file and insert the following code:

Redirect visits to a maintenance page

Insert the following code in the .htaccess file if you need to make changes to your website and you want it to appear “In maintenance”.

Configure the canonical URL

The canonical URL is the one we select to be indexed with Google. Copy the following code and replace it with the one you have selected to index.

Redirect to a page without www or with www

From a web without www to one with www

From a website with www to one without www

Redirects error page 301

Use the following code to redirect to a specific page without displaying the old error page.

Give access to your WordPress  Dashboard only from your IP

Replace the xx of this code with your IP so that only from it you can access the Administration Panel of your website in WordPress.

Avoid spam in your web comments

This trick will block access from non-referenced addresses, avoiding attacks and spam.

Secure WordPress plugins

While the plugins are increasingly updated in terms of security, with this code you can protect them from hackers and therefore protect your website.

Limit the upload weight of files to 20 MB

Note when you make this modification, since then you may have problems to upload larger files and you will be eating the coconut wondering why you can’t.

Block access to the wp-config file

A little more protection never hurts any website 😉

Add the slash (/) to the end of the URLs

To add a slash to the end of your links, insert the following code into your .htaccess file:

Protect the directories with passwords

Again, it’s never enough protection to the directories of your blogs.

Resolve errors in links (URLs)

Apply this trick to auto-correct misspellings of your links.

Force the cache

This code for the .htaccess will not help in the initial load of the web page or blog, but if it will do it significantly in later accesses, it shows states 304. This code indicates to the browser that the resources stored in the browser’s cache have not changed. It’s used to accelerate the delivery of web pages by reusing previously downloaded resources.

What other tricks do you apply? Tell us!

Jefferson Maldonado
the authorJefferson Maldonado
UX WordPress Designer
Ux & Web Designer. Portafolio: Divi Blogger, WordPress Expert, UX Designer, Business Consultant.

Leave a Reply