What does the $1 argument in this RewriteCond do? What does the $1 argument in this RewriteCond do? codeigniter codeigniter

What does the $1 argument in this RewriteCond do?


The $1 is basically the captured contents of everything from the start and the end of the string. In other words, $1 = (.*).

In your rewrite, the ^ signifies the start of the string, the (.*) says to match anything, and the $ signifies the end of the string. So, basically, it's saying grab everything from the start to the end of the string and assign that value to $1.

So if I type in www.example.com/tacos-are-good, then $1 = "tacos-are-good". So your end rewrite will actually be www.example.com/index.php/tacos-are-good.

Here's a cheat sheet for ModRewrite which may be of help:http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/


$1 represents the match from the first set of parentheses in the regular expression that follows it. ($2 would match the second set of parentheses - if given)

For example, the regular expression matches anything that is NOT "index.php" or "phpinfo.php", etc. So, the rewrite condition is passed if the requested url is not one of those, and the matched section is then passed to the rewriterule.