How to Resolve WordPress .htaccess File Writable Error While Updating Permalinks
WordPress and Permalinks
This post describes how to resolve the “If your .htaccess file were writable, we could do this automatically, …” error message in WordPress.
By default, WordPress creates ugly permalinks. This means that even though you write a post and title it “My Awesome Article“, the link that points to that article will be something “mywebsite.com/p=20“.
These are literally called ugly permalinks, so you will likely want to modify the rules for how wordpress builds your permalinks, and have a default more like “mywebsite.com/my-awesome-article“.
You can do this by going to Settings/Permalinks in the WordPress dashboard and choosing a new permalinks style.
But sometimes, something will go wrong here, and you will see two messages.
At the top of the Permalinks Settings, you see “You should update your .htaccess file now“.
And at the bottom you see “If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.”
First off, let’s talk about the .htaccess file. What is this thing? And who cares?
What is the .htaccess file?
The .htaccess file is usually created for you when WordPress is installed. It is a file that is used by the server whenever a user’s browser requests some files and allows the server to dictate rules such as where to look for those files.
Updating the permalinks requires a change to this file, and WordPress will attempt to make this change for you automatically. If it fails, you see the error message above.
How can I fix this?
There are a number of solutions you can try. I will list them in the order that you should try, with the easiest and more likely culprits first.
1. A mistake in your Site URL
This is a very common, and hard to diagnose cause of this error. Unless you are sure of what you are doing, you probably don’t want to change your Site URL. Changing the site URL allows the administrator of a site to install WordPress into a directory that is not the home directory.
The Site URL is NOT there for you to setup redirects or change your domain name or anything like that. So if your Site Address doesn’t match your WordPress Address, change it back. This will probably fix your permalinks issue!
2. A missing .htaccess file
In some cases you may just need to add the .htaccess file. This should be in the root directory of your wordpress installation (i.e. the same directory as index.php) and will need write permissions. For more info on how to set the permissions on your file, check out this WordPress codex article.
3. Continue on to the typical solutions
WordPress has compiled a great list of the more typical solutions. If neither #1 or #2 worked for you then consult this resource.
Any other suggestions you’d like to add? Comments or questions? Leave your thoughts below, or contact WebTO.