.htaccess--what's this line meaning?


RewriteEngine on  

 RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]

what’s the RewriteRule meaning? i can’t follow it well.expect someone can explain it. thank you.

To break it down:

^ - make sure we start matching at the start of a string, not somewhere in the middle
( - start an atom – which we can later get back by referencing $1
[^./]{3} - match anything but a dot or a slash exactly 3 times
[^.]* - match anything except a dot as many times as needed (greedy)
) - end of atom $1
$ - make sure we end matching at the end of the string, not somewhere in the middle

Then pass the matched information to /index.php?page=$1 where $1 is the string that was matched.

Does that make sense?

:tup: It certainly does to me!

However, I think I’d also hammer home that the redirect should not begin with the slash (because Apache will look to its root directory first THEN the site’s DocumentRoot).

Regards,

DK