Ruby on Rails
RewriteRule

A directive used by Apache’s URL rewriting engine(mod_rewrite).

A \RewriteRule specifies a pattern (regexp) and a string expression (which may refer to parts of the pattern). Any URLs that match the first pattern are changed (rewritten) to the value given by the string expression.

There are several optional flags that can be appended to the end of a RewriteRule such as [P] and [L]. Here is a brief summary of their effects:

See the complete list for details.

Rails used to depend more heavily on mod_rewrite, but present usage favours using Routes, which are more flexible, easier to maintain, and more portable.

category: Glossary