| 10:12 am on Jun 24, 2011 (gmt 0)|
$1 is the backreference to the regular expression bracket set on the right side. So, to break it up:
RewriteCond $1 \.(gif|jpg|ico|css|js)$ [NC,OR]
$1 would reference a matched file extension.
If you had more bracket sets in the regular expressions, you would have access to $1 and $2 and so on depending on the number of bracket combinations.
| 10:50 am on Jun 24, 2011 (gmt 0)|
And to which string the RewriteCond is applying the reg exp \.(gif|jpg|ico|css|js)$ ?
| 4:55 pm on Jun 24, 2011 (gmt 0)|
|$1 is the backreference to the regular expression bracket set on the right side. |
Assuming for the sake of discussion that your .htaccess is written in a right-to-left script. You can back-reference a previous capture, but you can't back-reference something that doesn't exist yet.
But you've got that page bookmarked already ;)
| 10:32 pm on Jun 24, 2011 (gmt 0)|
RewriteCond $1 !\.gif$
RewriteRule ^folder/(.*) http://www.example.com/$1 [R=301,L]
It might help to know that the RewriteCond is NOT processed first.
Processing order is:
^folder/(.*) pattern to see if "true",
- if true, the (.*) "creates" the $1 backreference (which essentially holds the requested "filename"),
- evaluate the RewriteCond; which checks if the requested "filename" does not end with ".gif",
- redirect to a new URL, one without "folder/" in it; the browser will have to make a new request.
| 8:39 pm on Jun 25, 2011 (gmt 0)|
Thanks, I got it now, it looks like more a forward reference rather than a back reference, in this case :v
| 9:47 pm on Jun 25, 2011 (gmt 0)|
Just remember that the RewriteRule RegEx pattern "creates" the $n references and the RewriteCond RegEx patterns "create" the %n references.
The numbering is ascertained by counting the opening parentheses, the first being $1 or %1.