It’s highly recommended that you understand the need for and how flags work when using rules with the .htaccess file.
In most cases, flags can be found at the very end of RewriteCond or RewriteRule commands.
Such commands are treated by Apache as directives to complete the following:
- start or stop processing certain rules and conditions
- process rule or condition as sensitive or case-insensitive
- group rules or conditions
- indicate first or last line of rule or condition
- skip one or a range rules or conditions
- force a specific mime type
- treat a condition or rule as a pass through
There are quite a few more and I recommend you review the Apache website for the full list of RewriteRule flags.
You can attempt to learn them, but I simply recommend keeping this aforementioned link handy as a bookmark.
In most cases, you’re likely to encounter one or more RewriteRule flags that are contained between brackets ([ ]), and comma-separated when more than one is declared.
Some of the most common flags you’ll likely use or encounter are as follows:
- S=x – Means to skip the next X number of rules, replace x with a number
- C – Means to chain or daisy chain with next rule
- L – Means the last rule and to stop processing rules
- N – Means the next rule and continue processing rules
- NC – Means case insensitive
- OR – Means to combine rules to use OR instead of implicit AND
- R – Means temporary redirect to a URL
- R=301 – Means permanent redirect to a URL
- QSA – Means to append the requested or submitted query string to substitute URL
- T – Means force a certain type of mime
Again, there are many other .htaccess flags to consider and account for when writing rules using RewriteRule.