Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I keep seeing the ^ character in RewriteRule statements in a context that doesn't fit with the usage specified here.

For example: RewriteRule ^(.*)$ $1.php [L,QSA]

What does it signify?

share|improve this question
    
Useful: mod_rewrite Cheat Sheet by DaveChild at addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet –  Anthony Hatzopoulos Jul 26 '12 at 13:49
add comment

1 Answer 1

up vote 6 down vote accepted

It means "this matches the start of the string". So in your example the rule does the rewrite if there's

  • the start of the string (^)
  • any character (.)
  • any number of characters (*)
  • the end of the string ($)

In other words, this whole expression matches any string.

share|improve this answer
    
Ah, of course. I always forget about the begin and end anchors. –  Maxpm Aug 31 '11 at 8:32
    
.* means 0 or more characters, so a zero length string matches too. –  pritaeas Aug 31 '11 at 8:59
    
Thanks @pritaeas for the update. I was doing it from memory. –  paulmorriss Aug 31 '11 at 9:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.