Adding Extra Security with the .htaccess file

Adding Extra Security with the .htaccess file

Here are some tips to keep your website more secure using the .htaccess file.     The .htaccess file is used on Apache servers to help secure your site and customise the behaviors of server requests.   Some of the more common uses of the .htaccess file are for URL redirects, URL re-writing and  controlling file and folder access.  Most hosting companies allow you to override your server configuration.   If they don’t, then you really should find a better host.

 

 

Tip #1 – Block malicious users IP address

This is only really useful if you find that the same IP address is harrassing you.   Most of the time, people are hiding behind a proxy.

 

Tip #2 – Block malicious query requests

This can be very valuable to your website.   This helps weed out a lot of sql injection attempts.  Of course, real security is data validation within your actual code.

 

Tip #3 -Block malicious user agents

When you go through your security logs, you will see an evolution of dirty user agents.   It’s almost like a bad flu that spreads.  I’ve recently encountered trouble with the HAVIJ tool, which allows for sql injection ‘testing’.   Most of the time, hackers use these tools to find vulnerable websites.  If your site is sending back a 403 response, then they most likely won’t come back.

 

Tip #4 -Disable directory listing

This will block a users attempt at browsing a directory and it’s files.  I find this to be very useful instead of inserting a blank index.html page.

 

Tip #5 – Whitelist your IP address

Put an .htaccess file in the directory that has access to your admin panel.  Note that this will only be useful if you have a static IP address that doesn’t change, otherwise you will effectively block yourself.

Tags:
No Comments

Sorry, the comment form is closed at this time.