How to create and edit htaccess file in WordPress

Many WordPress users are still not aware of .htaccess file and how to create it in WordPress. An .htaccess file is a low-level file that gives instructions to the server.WordPress uses it to create things like permalinks.

At some point when working with WordPress you will likely have to create and edit this file.The file goes directly in the root directory up the WordPress install and should have the file permissions set to 644.

Let’s see how to create and edit .htaccess file in WordPress, set its file permissions, then finally edit the file itself.

One of  the areas that you will need in .htaccess file for in WordPress is to make custom permalink settings. Permalinks determine what the URL’s of  your site will look like.

If you move from using the default ID based permalinks to doing something like postname base permalink which is more common and save those changes

Permalink Settings in WordPress

Permalink Settings in WordPress

you should get a message saying you should now update your .htaccess file

Update your htaccess file

Update your htaccess file

and down below on the bottom of the page we could see a message that says if your  htaccess file were writable WordPress would update this file for you automatically.

rewrite your htaccess file

rewrite your htaccess file

However because this file does not yet exist and is writable, you’ll have to manually update this file.What you are going to do is, creating .htaccess file, make it writeable, come back here update your settings and let Word Press do the rewriting for us.

To start off let’s go into our text editor and create a new file.We will leave this file blank for now and we’ll just go ahead and save it has .htaccess.

save as .htaccess

save as .htaccess

Now any time a file starts with dot it tells the system that this is not an ordinary file and then it’s actually giving instructions to the computer or the server itself.When you go to click save, it will give you a message about that and want to confirm that you do want to use a dot at the beginning over file name: You will go ahead and click use.

dot at the beginning over file name

dot at the beginning over file name

Now that after having this saved, jump over to the Finder and go ahead and look for this file that you just saved.

look for the htaccess file saved

look for the htaccess file saved

After saving it into this WordPress folder, you can see that it doesn’t show up here.The reason it doesn’t show up is that files that begin with the dot are usually reserved in hidden from view within finder. However if you use software like FileZilla or FTP software and you are coming look into that same folder, you can see that the .htaccess file is there, you are just not able to see it within finder.

using FileZilla or FTP software

Using FileZilla or FTP software

After dragging this file from your local server up onto your live server, you want to make sure that the file has the correct file permission so that WordPress can write to it.To do this  select the file, right click and check file permissions.

Click on file permissions

Click on file permissions

You can see that it is set to 755 which is actually okay. So we’ll go ahead and save this, come back into Word Press, refresh your page and click Save Changes again.

Change file attributes

Change file attributes

We can see that it says the permalink structure has been updated and WordPress is now taking care of editing your .htaccess file.

Permalink structure updated

Permalink structure updated

You may find that in some situations WordPress will automatically create .htaccess file for you but you will also often need to create this file on your own.  You should now know though everything you need in order to create and edit an .htaccess file.

Christine

Christine

Author at onlineshouter
Christine writes for people who seek for knowledge about SEO, blogging, online marketing, gadgets and web apps.
Christine

Leave a Reply

Your email address will not be published.