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:
- Launch your terminal app
ssh root@your_ip_addressto login
- enter your password to login to your Droplet
cd /var/www/html – this is your WordPress folder
ls -ato list all files (including hidden ones like htaccess)
- you will find
.htaccessfile 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:
vi .htaccessto open up the file in Vim
- Use the arrow keys to navigate to the line you want to edit
ito enter Edit mode
- when you’re done editing, press
esckey to exit Insert mode
:wqto 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
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.