Attention!
Before changing the .htaccess file, be sure to back it up.1 - Redirect WordPress RSS feed to feedburner using .htaccessWhy some webmasters do not use feedburner? After all, this is such a great tool for monitoring RSS feeds. The problem is that you have to fix template files with your hands. This reception will help save your time.
And do not forget to fix in line 6 to your code.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond% {HTTP_USER_AGENT}! FeedBurner [NC]
RewriteCond% {HTTP_USER_AGENT}! FeedValidator [NC]
RewriteRule ^ feed /? ([_ 0-9a-z -] +)? /? $ Http: //feeds2.feedburner.com/wordpress [R = 302, NC, L]
</ IfModule>
')
2 - Remove / category / from the path in the WordPress addressBy default, categories in WordPress are displayed like this: http://www.wordpress.com/blog/category/wordpress
And this is not very beautiful, and the address looks a bit long.
Now you will learn how to fix it with .htaccess
RewriteRule ^category/(.+)$ htt://www.yourblog.com/$1 [R=301,L]
Now categories will look like:
https: //www.wordpress.com/blog/wordpress
3 - Using Browser CacheA very good way to optimize your blog is to use the browser cache. This code improves browser caching of static files.
When you re-request a file that has not changed, the client will receive a response 304, and not the contents of the file.
FileETag MTime Size
<ifmodule mod_expires.c>
<filesmatch "\. (jpg | gif | png | css | js) $">
ExpiresActive on
ExpiresDefault "access plus 1 year"
</ filesmatch>
</ ifmodule>
4 - Static data compressionThis code will reduce the amount of data transferred between the server and the user due to their compression.
AddOutputFilterByType DEFLATE text / html text / plain text / xml application / xml application / xhtml + xml text / javascript text / css application / x-javascript
BrowserMatch ^ Mozilla / 4 gzip-only-text / html
BrowserMatch ^ Mozilla / 4.0 [678] no-gzip
BrowserMatch bMSIE! No-gzip! Gzip-only-text / html
5 - Redirect permalinks based on Day and name to /% postname% /First go to the WordPress admin panel, go to Settings → Permalinks and select custom.
Fill in the field with /% postname% /.
Now, permanent links will look like this:
https: //www.yourblog.com/name-of-the-postNow we need to redirect all the old links to the new permanent.
Add the following lines to .htaccess:
RedirectMatch 301 /( [0-9 ]+)/( [0-9 ]+ )/( [0-9 ]+)/(.*)$ https: //www.domain.com/$4
6 - Forbid commenting if referrer is missingThe method is based on the fact that many spam bots do not transmit the referer when they post data.
This code checks the referrer field and blocks sending a comment if referer is missing when accessing the wp-comments-post.php file.
Do not forget to enter the domain of your blog in line 4
RewriteEngine On
RewriteCond% {REQUEST_METHOD} POST
RewriteCond% {REQUEST_URI} .wp-comments-post \ .php *
RewriteCond% {HTTP_REFERER}!. * Yourblog.com. * [OR]
RewriteCond% {HTTP_USER_AGENT} ^ $
RewriteRule (. *) ^ Http: //% {REMOTE_ADDR} / $ [R = 301, L]
7 - Redirect the user to the stub pagewhile working on the site, it is desirable to redirect users to a temporary stub page
Replace in line 2 maintenance.html with the name of your file.
And in line 3, enter your IP so that you are not redirected to this stub.
302-redirek is used so that search engines do not index the contents of the temporary page.
RewriteEngine on
RewriteCond% {REQUEST_URI}! /Maintenance.html$
RewriteCond% {REMOTE_ADDR}! ^ 123 \ .123 \ .123 \ .123
RewriteRule $ /maintenance.html [R = 302, L]
8 - Protecting your blog from hotlinksHotlik is the use of files placed on your site on the pages of other sites in order to save your server traffic.
To combat this scourge will help the following lines in .htaccess
RewriteEngine On
#Replace? Mysite \ .com / with your blog url
RewriteCond% {HTTP_REFERER}! ^ Http: // (. + \.)? Mysite \ .com / [NC]
RewriteCond% {HTTP_REFERER}! ^ $
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule. * \. (Jpe? G | gif | bmp | png) $ /images/nohotlink.jpg [L]
9 - Allow wp-admin access only from your IPAn additional protection of your blog from hacking can be the restriction of the list of addresses from which it is allowed to enter the admin panel of the blog.
Do not forget to insert your IP in line 8.
If you want to use additional addresses for access, add the lines allow from xx.xx.xxx.xx
AuthUserFile / dev / null
AuthGroupFile / dev / null
AuthName "Example Access Control"
AuthType Basic
<LIMIT GET>
order deny, allow
deny from all
allow from xx.xx.xx.xx
</ LIMIT>
10 - Blocking spammers in WordPress via .htaccessOften spam bots come from the same IP. The following trick will help block access from these addresses.
Fill in the address of the spammer in line 3.
You can expand the list of blocked addresses by adding the lines deny from xxx.xx.xxx.xxx.
<Limit GET POST>
order allow, deny
deny from 200.49.176.139
allow from all
</ Limit>
UPD: The original article can be found
here . I came across by chance, but I could not ignore such utilities, and that’s what happened - this article.