I keep seeing the ^ character in RewriteRule statements in a context that doesn't fit with the usage specified in this document about regular expressions.

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

What does it signify?


1 Answer 1


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 the previous character (*)
  • the end of the string ($)

In other words, this whole expression matches any string.

  • Ah, of course. I always forget about the begin and end anchors.
    – Maxpm
    Aug 31, 2011 at 8:32
  • 2
    .* means 0 or more characters, so a zero length string matches too.
    – pritaeas
    Aug 31, 2011 at 8:59
  • Thanks @pritaeas for the update. I was doing it from memory. Aug 31, 2011 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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