Creating a WordPress .Htaccess File

WordPress being a self hosted Blog, you get the flexibility to play with root folder. Today I’m going to talk about WordPress .htaccess file which is an important file for many reasons. You can set many security settings using Wp .htaccess file, add rules for redirection, block bots, secure your blog from spammers and many more.

Though, many Wp users who are hosting their own blog are still not aware of .htaccess file and how to create .htaccess file in WordPress. Today, we will learn many aspect of WordPress .htaccess file and in future tutorials, I will share some useful codes which you can add to keep your blog secure.

What is WordPress .htaccess file:

.Htaccess file is not only associated with WordPress, but any Apache webhosting offers .htaccess file feature. When you install WordPress, in most of the cases it comes by default but stay in hidden mode at the root of your WordPress installation. Some time, .htaccess file is not present, and you have to manually create .htaccess file in WordPress. We can use a normal text editor to update or remove the content of our Wp blog .htaccess file. This is default code for your WordPress htaccess file:

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

# END WordPress

Here is a question asked by one of our reader Kashish: Hi, I want to edit my Permalink to /%postname? in WordPress and it’s showing now to add some code in my .htaccess.txt file, but I could not find it anywhere in my dashboard or root directory. How do I create WordPress .htaccess file and add the code into it?

How to create WordPress Htaccess file?

In most of wordpress blog .htaccess file resides by default in the root of wordpress installation. If you.htaccess are using Filezilla FTP client, you can refer to my post on how to edit your .htaccess file. all you need to do is click on force showing hidden file, from the option menu, which is already explained earlier. In case .htaccess file does not exist, simply create a new notepad file (htaccess.txt) and rename it to .htaccess. Make sure, it should not be like .htaccess.txt in any ways. If you using windows you can uncheck the option which says hide extension of known file type. hide_extension

Once you have renamed the file to .htaccess, upload it to the root of wordpress installation and edit your file according to your need. In case you having hard time renaming from htaccess.txt to .htaccess, simple upload the htaccess.txt file and rename it on the server.

Default permission for security of .htaccess file is 644 but at times when you are changing permalink and WP is unable to access your .htaccess file, you can change it’s permission to 777 and update it. Though, make sure to change it’s permission to 644, else it would cause security issues.

Do let us know if you have any queries regarding WordPress htaccess file, and I would love to answer your query. Don’t forget to subscribe to my Email newsletter for more Wp tips.

Leave a Reply

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