All about the WordPress .htaccess file

A WordPress website owner has probably already come across it once, the WordPress .htaccess file. For many people, this is still an unknown file, until you have to deal with it once. The .htaccess file is a file that is hidden. It is only visible in programs if you enable that you want to see hidden files. Read more about what the file is.

What is the WordPress .htaccess file?

A .htaccess file from WordPress is a text file with which you can override the configuration settings. A configuration ensures that a system has the right functionalities. The file contains textual information that the server can read. Via a .htaccess file you can also change the settings for WordPress. It is also often used to create a better permalink structure to use and manage.

Advantages of .htaccess file

With a .htaccess you can, among other things, block IP addresses, redirect, adjust error messages, protect folders and enable the rewrite engine. Many plugins also use the file to efficiently display cached content, set up automatic redirects, forward HTTP to HTTPS and increase the maximum upload size.

Why is the .htaccess file important?

The .htaccess file is an important file of WordPress. The file controls the rewriting of the URLs. This way, every page is easily accessible to visitors. Moreover, with the file you can also make your WordPress installation safer and block hackers or unwanted visitors from your WordPress website.

Where is the .htaccess file in WordPress?

You can find the .htaccess file in the folder of your web server. All the files of your website are stored in this folder. To find this you need an FTP program. With that you connect to the WordPress website and you can get to the .htaccess file. Often, “point files,” the files that begin with a period (.), are hidden by default. So first enable the option to show these files in the folder.

htaceess file in an ftp environment

How do I create the .htaccess file in WordPress?

If there is no .htaccess file on the server, you can also create one yourself. You do this with a text editor, think of notepad or notepad. After entering the lines or code, save the file as ‘.htaccess‘. Place this file on the server in the folder where you want to apply the lines from the text. Note: if you have a .htaccess file in both the root folder and a subfolder, the version in the subfolder will be overruled.
If you install WordPress via a hosting provider, the system often comes with a standard .htaccess file. This file is also called the ‘WordPress default .htaccess file’.

Use the following code if you want to make it yourself:

># BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./index.php [L]

Examples of common .htaccess rules

Time required: 10 minutes.

Via a .htaccess file you can perform various actions. The following rules are often used:

  • Block IP address

    If you have an IP address that receives a lot of requests, you can simply block it with the following rules:
    – order deny,allow
    – deny from [ip adres]
    – deny from [ip adres]
    – allow from all

  • Refer

    You can enable referrals in different ways. The easiest line looks like this:
    – redirect 301/verkeerd.html /correct.html

  • Customize error messages

    You can upload self-written error messages as follows:
    – ErrorDocument 403 /fouten/geen-toegang.html
    – ErrorDocument 404 /fouten/niet-gevonden.html

    The most commonly used codes are:
    401: Unauthorized (Visitor is not logged in)
    403: Forbidden (Visitor does not have access to the page)
    404: Not Found
    500: Internal Server Error

Always make a backup

As you can see, a lot is possible with the .htaccess file. Make sure you have a backup of the .htaccess file before you make any adjustments to your WordPress website. An unconscious little mistake can cause your entire WordPress website to be inaccessible. Read at our service WordPress Backups the need for a backup.

Need help with the WordPress Htaccess file?

If it has not succeeded with your .htaccess changes or does your website no longer work? No problem! Contact our WordPress specialists and they can see what is going on with your website. You can reach us by starting a chat or calling us at 030 20 72 488. Are you curious about what kind of services WPonderhoud offers? Take a look at our WordPress Maintenance Packages.

© WPmaintenance.com 2011 - 2022 | All rights reserved | WordPress Maintenance is part of Artitex