The .htaccess file is a server configuration file. It allows you to define rules for your server to follow for your website.
Here are some useful .htaccess tricks for your WordPress site.
Protect Your WordPress Configuration wp-config.php File
Probably the most important file in your WordPress website’s root directory is wp-config.php file. To protect your wp-config.php file from unathorized access, simply add this code to your .htaccess file:
<files wp-config.php> order allow,deny deny from all </files>
Setting up 301 Redirects Through .htaccess File
Using 301 redirects is the most SEO friendly way to tell your users that a content has moved to a new location. If you want to quickly setup redirects, then all you need to do is paste this code in your .htaccess file.
Redirect 301 /oldurl/ http://www.example.com/newurl Redirect 301 /category/television/ http://www.example.com/category/tv/
Ban Suspicious IP Addresses
Are you seeing unusually high requests to your website from a specific IP address? You can easily block those requests by blocking the IP address in your .htaccess file.
<Limit GET POST> order allow,deny deny from xxx.xxx.xx.x allow from all </Limit>
Protect .htaccess From Unauthorized Access
As you have seen that there are so many things that can be done using the .htaccess file. Due to the power and control it has on your web server, it is important to protect it from unauthorized access by hackers.
<files ~ "^.*\.([Hh][Tt][Aa])"> order allow,deny deny from all satisfy all </files>
Increase File Upload Size in WordPress
There are different ways to increase the file upload size limit in WordPress. However, for users on shared hosting some of these methods do not work.
One of the methods that has worked for many users is by adding following code to their .htaccess file:
php_value upload_max_filesize 64M php_value post_max_size 64M php_value max_execution_time 300 php_value max_input_time 300 Source: http://www.wpbeginner.com/wp-tutorials/9-most-useful-htaccess-tricks-for-wordpress/