In this article, I will introduce you to a .htaccess file? Explain how it works and how to edit it. From there, you can find tips for using .htaccess file better.

Keeping the site safe is one of the important tasks of every admin.

While WordPress is one of the largest CMSs available today, hackers will pay more attention to you.

So how to secure your WordPress site. Happily, there are many ways, without you being a coder or developer.

You can take advantage of the power of the .htaccess file to increase WordPress security.

What is a .htaccess file?

The .htaccess file stands for ” HyperText Access “, it is a configuration file on the Apache webserver, it is used in quite a lot of WordPress sites.

For simplicity, .htaccess is a file that controls how the file is accessed in a directory.

This is a powerful tool to improve security and performance on WordPress.

Just through a few small tweaks, you can do a lot of things like block users, create redirects, prevent attacks, ban access in some areas of the website …

How to Edit .htaccess File

By default, the .htaccess file is available when installing WordPress. Normally you will find it right in the root directory of WordPress. It only has a single file and does not contain any other files or extensions.

Simply open it with notepad or notepad ++ or any similar software

A basic .htaccess file will look like this.

Note: You must not add any code or edit it to the paragraph #BEGIN and #END. It is best to add a new paragraph below it.

After you add some code, remember to save it. If you insert quite a lot of different code, do not add them at the same time.

Take turns one by one, if you encounter an error you will know which code it has been fixed.

But in some cases, you won’t be able to see it for editing.

Why can’t you find the .htaccess file?

The period before the file name indicates that it is a hidden file. If you are accessing the server via the FTP Client sometimes you will not see it

Because it’s hidden, now you’ll need to select ” Force showing hidden files ”

But you still do not see the .htaccess file even if turned on must be hidden then …

The most common reason is that your website has not created a .htaccess file yet. By default, WordPress will have this file on the first set of permalinks Settings » Permalinks.

All you need to do is click the Save Changes button on the Permalinks screen and WordPress will create it in the root of your website.

In some cases, WordPress does not have permission to create a .htaccess file because there is no write permission.

In that case, WordPress will show you a notification at the bottom of the Settings »Permalinks screen, informing you that the .htaccess file is not writable.

If you set the permalink to use settings other than the default, it will also show you the code you need to paste into the .htaccess file.

WordPress shows the message that the .htaccess file is not writable.

Simply copy the following code and paste it into notepad and save it as .htaccess. Then upload it to the WordPress root directory

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule. /index.php [L]
</IfModule>
# END WordPress

If you get an error when you upload that file, then you will need to change the File Permissions. Let’s assume all your WordPress files are under /home/domain name/public_html/.

This makes public_html your root directory. You need to go to its parent directory and right-click on the public_html directory.

Select File Permissions, the file will open a file permissions dialog. You need to enter 755 for that dialog box and then try to upload your .htaccess file to the public_html directory.

Find .htaccess File on hosting with Cpanel

If you are using hosting with Cpanel then everything is quite simple. First, log into your hosting account and select File Manager in the File section

You should see the .htaccess file in the public_html directory
If it doesn’t, select Settings (in the upper right corner of the screen) and select Show Hidden File.

If your hosting does not have or create a file. Select the icon + File left corner or left mouse space New File. Enter the name of the .htaccess file and click Create New File.

I hope this article helped you find or create a .htaccess file on WordPress website.

If you’re just starting out with WordPress, don’t forget to check out the beginner’s guide, here are specific instructions for those new to WordPress.

Let me know if you have any questions or feedback in your comment below.

Author

Hy Visitor Welcome To "WPHaxs" I'm Abdul Rehman From Pakistan and Working on Social Media Since 2013 and I'm Sharing Some Cool Tips and Tricks To Make Your Blog Look Cool and SEO Friendly

Write A Comment

WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
👋 Hi, how can I help?