Wordpress Hacks- .HtAccess {Hypertext Access} Part 1
Author: ziashaikh_97 | Filed under: HacksHey Guyz!!
Do you have a Wordpress Powered Blog and dont know the main uses of the .htaccess file in the root directory?
I have got a solution for you, .htaccess file in the root directory of wordpress is a file which is used to configure your blog according to your needs.
I will give you the script with its affect below.
Below are the uses of wordpress which I do:- {You will really like them all}
GZip Files
GZip allows you to compress files which means it will load faster. The script below will GZip- html, text, css, js and php files.
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
Stop Hotlinking
When someone hotlinks an image on your blog, then its using your resources and so is slowing doing your site. Its really easy to stop hotlinking using the below script.
#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomainhere.com/.*$ [NC]
#RewriteRule \.(gif|jpg)$ - [F]
RewriteRule \.(gif|jpg)$ http://www.yourdomainhere.com/stophotlinking.jpg [R,L]
Stop Spammers
Like Hotlinking, when a spammer comments it using your resources and slowing your blog. So the below script will stop no referrer steps and the spammers too.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*ultramaxzone.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
PHP Compression
Once again a compression technique but this time for PHP. It will convert your blog PHP into 1 kb or a bit more! Use it with caution or else you will end up with nothing.
# php compression – use with caution
<ifmodule mod_php4.c>
php_value zlib.output_compression 16386
</ifmodule>
.HtAccess Protection
Want to protect .htaccess file from hackers? Then use the below script.
# STRONG HTACCESS PROTECTION</code>
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
Disable Directory Browsing
Dont want to let someone know which wordpress plugin ou are using? Then below is the right script for you.
# disable directory browsing
Options All -Indexes
Block Someone
Dont want someone to see your blog? You can block them using their ip.Then below is the script made for you. In xx.xx.xx.xx type in with the spammers IP address. If you want to block multiple IP then put 1 per line.
<Limit GET POST PUT>
order allow,
deny from 00.000.000.00
Allow from all
</LIMIT>
Protect WP-Config
A Famous Blog? Want to protect WP-Config from being hacked? Then Use the below script.
# protect wpconfig.php
<files wp-config.php>
order allow,deny
deny from all
</files>
Redirect Wordpress Content Feeds to FeedBurner
Using the below script you redirect content feeds to feedburner.
# temp redirect wordpress content feeds to feedburner
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/yourfeedhere [R=302,NC,L]
</IfModule>
Error Message
If someone gets some error in doing some type of comments etc. the owners email address could be displayed for help.
SetEnv SERVER_ADMIN youremailid@emailprovider.com
Correct Links
Below script will automatically correct link which you had mistaken in spelling.
<IfModule mod_speling.c>
CheckSpelling On
</IfModule>
If you enjoyed this post, make sure you subscribe to my RSS feed!
Tags: .htaccess, Hacks, hyperlink access, Scripts, Wordpress
November 25th, 2009 at 10:42 pm
Fantastic, I didn’t know about this topic till now. Thx.
January 4th, 2010 at 4:42 am
Thx for the article!