Notes On .htaccess

This is something I need documented for myself, so here we go!

Without htaccess

Here’s what I see when I view my localhost without the htaccess file. This is the same as having Options +Indexes in the htaccess file.

With htaccess minus Indexes

If we create a .htaccess file in the root directory and then add this piece of code Options -Indexes, it’ll return a forbidden error message as follows –


Adding another line IndexOptions FancyIndexing results in this –

Other tips

  • Usually the default index file is index.php, you can change that to main.php by using DirectoryIndex main.php
  • You can ignore specific files using IndexIgnore *.txt *.css and they’ll stop showing up in the Index
  • You can parse somefile.abcd as php as follows: AddType application/x-httpd-php .abcd

Deny A File

You can deny a file using order allow,deny as follows:

Note that there’s no space between allow and deny. A space would result in a misconfigured .htaccess file.

The same can be done for multiple file extensions using FilesMatch regular-expression> tag where you add in some regular expression like "\.(txt|css)$" to match the required file extensions.

Using Terminal To SSH

You can use FTP, SFTP and even SSH using username and password but SSH can also be done via key based authentication via terminal. I want to document this for myself and others as this is pretty helpful in my job as a support engineer.

Saving the key!

First, you’d need to obtain the key and save it on your desktop. You can just save it without any extension, that’s okay. Next make sure to set it’s permissions to read only else it’d return an error as follows –

To avoid that error, make sure to run this command: chmod 400 key where key is your file name.

Logging in via Terminal

  • The command to connect is: ssh username@host -i <path to key>.
  • That should get you logged in where you can look around
  • using change directory cd command,
  • see your present working directory using pwd
  • and edit files using nano <filename>.

In case you see permission denied error while editing a file, you can always use sudo command. For example sudo nano <filename> and that’ll do.

Once you’re done editing, you can escape the file by ctrl+x and when you’re done with the session, you can quit using the exit command.

That’s all in this post! 🙂

Github Basic Terminal Commands

I’m one of those people who’ve struggled understanding Github terminal commands. Now that I finally understand some of it, I’d like to share this here on my blog. This post will cover the basics that you need to know to get started and use GH comfortably 🙂

Installing Git

The instructions to install git and everything around it can be found on the official git website . Just download the installer and install git on your computer.

Creating a repository on GitHub

This is pretty simple and intuitive. You need to have a GH account. Create on on and then just create a new repository. You can follow their documentation if needed.

Pushing your files to GitHub

Let’s say you create a new repo which says coolest-addon and you have this coolest add-on ready in a folder on your desktop. You can then push it to GitHub by following this guide or by following the instructions below!

  1. Open the terminal and switch to your coolest-addon folder by using the cd command. I’d do something like cd ~/desktop/coolest-addon
  2. Next use git init
  3. Add all files using git add .
  4. They’re now ready to be commited.
  5. Write git commit -m "First commit"
  6. Add URL for remote repo git remote add origin <remoteRepositoryURL> (without the angle brackets)
  7. And finally push using git push -u origin master


I suggest reading this Stackoverflow thread before you dive in branching. Also checkout this flow for a better understanding about branches. The commands you’d need to remember are:

  1. git checkout to see if your branch is up to date
  2. git branch to see all branches and also to see the active one
  3. git checkout <branch-name> to switch to a branch
  4. git checkout -b <branch-name> to create a new branch and check it out
  5. git push -u origin <branch-name> to push your new branch
  6. git pull to pull changes to your branch

People working on the same project can check your new branch using these two commands:

  1. git fetch
  2. git checkout origin/your_branch

Spoon Knife

I personally learn things by practice, by actually doing them. Starting with Github is tough for most people because we’re scared that we’ll break something or that we’ll make a mistake which’ll be a public embarassment for us. Something that’ll be documented online.

To overcome this fear, you can experiment in a repo called Spoon Knife. The repo is made for beginners to test things out. So feel free to perform experiments there 😀

  1. Specifically, when you visit that repo, fork it to your repositories.
  2. Go through the readme file and make changes in it.
  3. Create branches, pull requests, merge those PRs, delete branches.
  4. Do everything you can till you get it.

That’s all in this post! 🙂

Simple Admin Page Form

This code creates a form to enter scripts or content which will be saved to the db and then fetched from it.

This results in a form as follows:

You can find this plugin in the Github repo here! 🙂

Adding Scripts To Header And Footer

Here’s how we can add things to the header and footer in WordPress:

Again, this is just me documenting things for myself. Which is why these posts aren’t super detailed 🙂