I have been using the Apache HTTP Server since early 2000’s, and it only continues to get better. While most people don’t need to know how to set it up from scratch and configure it, you should know how to use the htaccess file. If you create a file named “.htaccess” in the “public_html” folder of your website, you can do some really neat things. I’ll cover three things everyone using Apache should know.

Block Users With htaccess

You may find yourself wanting to block a certain visit from your site, and that’s okay, but how do you do it?

allow from all<br /> deny from # blocks one IP address<br /> deny from 1.3 # blocks every IP beginning with 1.3

SEO Friendly URLs With htaccess

If you’re tired of having “index.php” in your URLs, I don’t blame you. Below is a snippet you can add to your htaccess file to easily rewrite your URLs to remove it. Doing it this way, you don’t have to change any of your code, just add the snippet below.

RewriteEngine On<br /> RewriteBase /

# Removes index.php<br /> RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]<br /> RewriteCond %{REQUEST_FILENAME} !-f<br /> RewriteCond %{REQUEST_FILENAME} !-d<br /> RewriteRule ^(.*)$ /index.php/$1 [L]

`# If 404s, “No Input File” or every URL returns the same thing

make it /index.php?/$1 above (add the question mark)`

Forcing HTTPS With htaccess

If your site has an SSL certificate, then I recommend you force your users to use it. That green “Secure” text in the address bar makes everyone feel a little safer, and it helps with SEO.

RewriteEngine On<br /> RewriteCond %{HTTPS} !on<br /> RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


While nginx gets all the attention lately, we can’t forget about Apache HTTP Server because it’s going to be around for quite awhile. Be sure to check out the Apache docs or leave a question below.

If you are familiar with Apache but would like to try nginx, you could always use nginx as a reverse proxy.