Advanced .htaccess Tips
.htaccess is the default file name of an optional configuration file that provides numerous commands for controlling and configuring the Apache Web Server, and also to control and configure modules such as mod_rewrite (for htaccess rewrite), mod_alias (for htaccess redirects), and mod_ssl (for controlling SSL connections).
This file is usually present in the root directory and enables theWordPress „friendly-url“ permalink structure for example.
You can create a .htaccess file in any folder to to add restrictions specific to the folder (and all sub-folders).
You can create a .htaccess file in any folder to to add restrictions specific to the folder (and all sub-folders).
Before making any changes – make sure to backup the current .htaccess file!
Protecting specific folders: – create a htaccess in the folder required
or else:
If you are using this to protect /wp-admin/ directory then add the following to allow user logins (for comments etc.)
Block Referrer Spam (you’ll see these clogging your analytics traffic):
Stop Spammers automatically posting Spam comments on your Blog:
Trap almost all bots trying to hack your site.
First, set a cookie for anybody requesting resources.
Second, check incoming POST’s to see if they have that cookie set, if not, you can assume that they are most likely bots.
# Block most proxies. Most hackers / spammers use proxies
# You might want to only use this on restricted resources (logins, comments) – as this will also block
Block the most common hacker attacks used to compromise your site
Having secured your server you still need to be vigilant and follow basic security procedures:
Apply all UPDATES !!
Use STRONG passwords and don’t reuse them!
Regularly create Backups
If you are not sure if your server has been hacked – use a free malware scanner to check:
PS: If you are using nginx Server and not Apache, use this Site to convert htaccess commands into nginx compatible commands – http://winginx.com/en/htaccess