adric: (Hacker)
adric ([personal profile] adric) wrote2007-10-03 09:32 pm
Entry tags:

RegEx Drain Brammage

Whats this do? ^([^.?]+)$ Or rather, how does it do it, and why wouldn't something simpler work, like ^(.+)$ ?

in:
RewriteEngine on
# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
from: http://us2.php.net/manual/en/security.hiding.php#72630


From beginning of line (^) to end of line ($) match () one-or-more (+) of ... not-character followed by a question mark ?? ... or perhaps zero-or-more not-characters ?

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org