0

Please help me to know what is the meaning of below .htaccess code. What it does every line of it.

RewriteCond %{HTTP_USER_AGENT} ^$ [OR]

RewriteCond %{HTTP_USER_AGENT} (bot|crawl|robot)

RewriteCond %{HTTP_USER_AGENT} !(bing|Google|msn|MSR|Twitter|Yandex) [NC]

RewriteRule ^/?.*$ "http\:\/\/127\.0\.0\.1" [R,L]
user3438096
  • 77
  • 2
  • 12
  • RTMF : http://httpd.apache.org/docs/current/mod/mod_rewrite.html – Amit Verma Mar 05 '16 at 07:02
  • Have you attempted to search on mod_rewrite directives? There are a wealth of such information available online which breaks down each directive. – shrmn Mar 05 '16 at 07:07
  • Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – shrmn Mar 05 '16 at 07:08
  • Your RewriteRule is conditional and it is applied only on these conditions (if uger-agent value is empty **cond 1** ) (Or user-agent is "bot|robot" **cond 2**) (and user-agent is not "bing|google.. **cond 3** ) if all those conditions are met then the rule is applied. – Amit Verma Mar 05 '16 at 07:26

1 Answers1

1

In basic language:
This code is used to try to control robots that are crawling/spidering your site, by allowing just bing|Google|msn|MSR|Twitter|Yandex to do so and send all others to a dead end.

lines 1-3 describe the conditions for the action in line 4:
1 = if HTTP_USER_AGENT is knocking on the door [OR]
2 = if HTTP_USER_AGENT is a robot, crawler or spider
3 = and if HTTP_USER_AGENT is not one of the listed ones [case INsensitive]
4a = [RewriteRule] = you are going to give another address to go to (instead of searching in your site)
4b = [^/?.*$] = for everything they want to look for
4c = you send them to their own navel (local host) [R = redirecting them, and L = stopping the the execution of the rule set]

E.C.Pabon
  • 247
  • 1
  • 8