WordPress .htaccess File

0 Comments

How to Create the Default WordPress .htaccess File

Running into an obstacle when updating the .htaccess file? Or perhaps you accidentally deleted that important file? Well, don’t push the panic button just yet. Keep scrolling and learn how to create the default WordPress .htaccess file so you can configure some additional settings for your site.

What Is the .htaccess File?

The .htaccess file is an essential WordPress’ core file to reconfigure specific settings of the Apache Web Server. This file helps you enable or disable certain features of your server, like creating a redirection from non-www to www URLs or resetting permalinks structure.

Additionally, the .htaccess file can handle your WordPress security settings. You can use it to set up privileges for particular files, configure password protection, and block spambots.

Once you’ve installed WordPress on the Apache webserver, you can find the .htaccess file in your root directory. However, this file is usually hidden, so you need to enable the Show Hidden Files option to access it.

But in some rare instances, your WordPress installation may not contain the .htaccess file. Thankfully, you can manually create the default .htaccess file using your hosting control panel.

How to Create the Default WordPress .htaccess File?

    1. Navigate to Files -> File Manager.
    2. Select your site’s domain and hit ​Go to File Manager.
    3. Go to the public_html folder and click the New File icon at the top of the page. Then, name the file “.htaccess”.
    4. Open the new WordPress .htaccess file and paste the following code:# BEGIN WordPressRewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ – [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

      # END WordPress

 

5. Hit Save & Close.

Alternatively, you can create the default .htaccess file using any text editor on your computer (e.g., Notepad), then upload it to your web server via an FTP client.

Congratulations! You’ve successfully created your default WordPress .htaccess file. Next, visit your WordPress website to ensure that the file works properly. Often, incorrect .htaccess configuration triggers 500 internal errors.

Conclusion

The .htaccess file makes your website work properly. It tells the server how to run your website, or determines what content to load. Equally important, you can use this file to set up WordPress security settings, such as preventing or blocking spambots.

In this tutorial, you’ve learned how to create the default WordPress .htaccess file. Simply create a new file in the public_html folder, name it .htaccess, and insert the default .htaccess code.

Share with your Friends

Leave a Reply

Your email address will not be published. Required fields are marked *

shares