How to Find And Edit .htaccess File in Your DigitalOcean WordPress

Where is the htaccess file location in Linux?

I messed up my .htaccess file and now to WordPress website cannot be accessed.

The most direct way to access your htaccess file is to login to your server (or Droplet in DigitalOcean) with SSH.

It can be a daunting experience if you’re like me, no experience with *nix commands and server environments.

Nevertheless with the help of Google, I got my WordPress up and running again.

Locating htaccess file

Here are the steps:

  1. Launch your terminal app
  2. enter ssh root@your_ip_address to login
  3. enter your password to login to your Droplet
  4. enter cd /var/www/html – this is your WordPress folder
  5. enter ls -a to list all files (including hidden ones like htaccess)
  6. you will find .htaccess file in that folder

Still confused? Read DigitalOcean’s guide on connecting to your Droplet via SSH.

Editing htaccess file

From here, you could edit the htaccess file directly with Vim – a text editor – to correct your mistake.

Quick summary on using Vim:

  • Enter vi .htaccess to open up the file in Vim
  • Use the arrow keys to navigate to the line you want to edit
  • i to enter Edit mode
  • when you’re done editing, press esc key to exit Insert mode
  • enter :wq to save and quit Vim

Want to do more with Vim? Learn more on how to use vim commands.

Alternatively, if you have already backed-up your htaccess or you simply want to reset it, delete the file by entering rm .htaccess.

Access WordPress files via plugin

If you find yourself frequently accessing your WordPress folder, save your trouble by installing the File Manager plugin in your WordPress. This plugin allows you to access and edit files directly within your dashboard.

Leave a Reply

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