Jen
Jen

Reputation: 23

RewriteRule Meaning

What does the below line means and what does it do? I know with the RewriteCond it is used to block access by user agent. My guess is it allows the agent to access the robots.txt but block if it try to access everything else?

RewriteRule !^robots\.txt$ - [F] 

Upvotes: 1

Views: 49

Answers (1)

Jon Lin
Jon Lin

Reputation: 143856

The syntax for a rewrite rule is:

RewriteRule <URI regex> <target> <flags>

Here, the URI's regex is saying "NOT /robots.txt".

The target is "-" which means "Do nothing and let the rule get applied".

And the flag says "return with a 403 forbidden".

So essentially, this rule is saying a request made to anything except /robots.txt will result in a 403 Forbidden response.

Upvotes: 1

Related Questions