What is WordPress Default htaccess File Contents?

What is WordPress Default htaccess File Contents? Web servers running on the Apache Web Server software need the .htaccess configuration file. You can adjust your website on an Apache server using your WordPress .htaccess file. Read along to learn more!

Updated: 07 Nov, 22 by Susith Nonis 6 Min

List of content you will read in this article:

If you missed some configuration in WordPress htaccess file or have completely missed that file, you can use this article to get WordPress default htaccess file contents. First, we should know what is htaccess file and how it works. Web servers running on the Apache Web Server software need the .htaccess configuration file to run. The .htaccess file is loaded through the Apache Web Server after being placed in a directory. After loading, the .htaccess file is executed by the Apache Web Server software.

What does this mean? The files can be adjusted to the configurations of the Apache server software. The user can enable or disable the Web Server software's features and functionalities. 

In WordPress, .htaccess controls how your server runs your site. .htaccess is one of the most powerful configuration files capable of controlling SSL connections, password protection, 301 redirects, and your default language, to mention a few.

The file essentially offers commands for configuring and controlling the Apache Web Server. Note that the Apache Web Server hosts thousands of server farms or websites. If the configuration site were not there, all the websites would have the same settings. 

With the file, you can build a unique WordPress website through the configuration of different settings, force SSL, control access to sensitive files, block IP addresses, send custom HTTP responses on certain requests, and prevent hotlinking.

To find the .htaccess configuration file, you need to open your WordPress site's root directory. The name of your root directory could be httpdocs, htdocs, www, or public HTML, depending on your hosting provider. 

You can also locate .htaccess through your account's cPanel. Here are the steps:

  1. Open your file manager
  2. On the left side of your screen, open the public HTML folder
  3. Under the HTML folder, open the "WordPress" folder
  4. Search for .htaccess file within the WordPress folder

If you cannot locate the .htaccess file, it does not exist. The good thing is that you can create it.

By default, your WordPress site will use .htaccess to enable and disable features on Apache, operate caching and security plugins, and manage redirects and permalink structures.

The .htaccess file allows you to make basic and advanced configuration changes. That could be considered simple changes like changing the time zone of your website to advanced configurations like rewriting URLs, setting up redirects, customizing error pages, and password protection.

To access the WordPress default .htaccess page, follow the procedure highlighted above. Sometimes, WordPress will not automatically create the .htaccess files for you. In this case, you are required to do it manually. Here are the steps.

  1. Go to your WordPress dashboard, select "Settings," then click on "Permalinks."
  2. Scroll to the bottom of the page and save the changes. However, remember that you should not make any changes to the permalinks.
  3. Once you save the changes, WordPress will generate the configuration file. You will get feedback that the file is not writeable if it cannot. This is a cue to create the configuration file.
  4. Create the .htaccess file by first opening the file manager. Open the public HTML folder on the left side of the screen and click on the "File" icon.
  5. In the field provided, type in ".htaccess" and then click "Create New File."
  6. Edit the newly created file and add the code below

BEGIN WordPress

 RewriteEngine On

 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

 RewriteBase /

 RewriteRule ^index\.php$ - [L]

 RewriteCond %{REQUEST_FILENAME} !-f

 RewriteCond %{REQUEST_FILENAME} !-d

 RewriteRule . /index.php [L]

 # END WordPress

  1. Once done, save and close the file.

Now that you know how to create a .htaccess file on WordPress, the next thing to learn is how to edit the file. You can edit the .htaccess file to override the setting or configurations in your web server. There are three methods for editing WordPress .htaccess.

You can edit it from cPanel, using FTP clients or a plugin.

1. Editing .htaccess File From cPanel

  1. Navigate to the File Manager

To access the file manager, log into your hosting account, and open cPanel. Under it, choose File Manager.

  1. Select the public HTML folder

Under the File Manager, select the public HTML folder. Search for the .htaccess file in the folder and right-click.

  1. Select edit

Click edit, then insert your modifications.

2. Editing Using FTP Clients

You can edit the .htaccess configuration using an FTP client. The FTP client allows you to access your website from a local computer.

You must install the FTP client and connect the software to your website. Once connected, locate the .htaccess from your local computer. Depending on your FTP client, you will mostly find the file from the "remote site" option.

From the remote site:

  1. Open public HTML

Under the remote site, search for the public HTML folder. Under this folder, find the .htaccess file and right-click.

  1. Click edit

Click edit and make modifications.

3. Editing Using a Plugin

Using a plugin for editing is a good option for the web owner looking for a simpler process and is afraid to make mistakes on their website files. First, ensure that the plugin you have selected is compatible with your website, lest it will cause your website issues.

Once you install the plugin, go to your website's dashboard and select settings options. Under settings, select the plugin, and often, you will be prompted directly to the .htaccess file. You can then make modifications to the code and save your changes.

You can adjust your website on an Apache server using your WordPress .htaccess file. To make the modifications, you must locate the configuration file. One of the ways to locate your .htaccess is through your account's cPanel.

In some cases, you may not locate the file, which indicates that it does not exist and you have to create it. To control your website on Apache Web Server, manage passwords, set up redirects, or rewrite URLs, you need to know how to access and edit the configuration file.

The guides above will help you locate the .htaccess file and edit it to make configurations.

People also read:

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.