Forum Moderators: phranque
RewriteCond %{REQUEST_URI} !^/example/(foo|bar) [NC]
RewriteRule ^example/([-\w]+?)/? target.php?id=$1 [NC,QSA,NE,L] // doesn't match
RewriteRule ^example/(!foo|bar)/?$ target.php?id=$1 [NC,QSA,NE,L]
RewriteRule ^example/!(foo|bar)/?$ target.php?id=$1 [NC,QSA,NE,L]
RewriteRule ^example/(!foo|!bar)/?$ target.php?id=$1 [NC,QSA,NE,L]
// this matches, but it would catch strings that don't begin with example, too
RewriteRule !^example/(foo|bar)/?$ target.php?id=$1 [NC,QSA,NE,L]
// I tried negative lookahead, but these didn't match, either
RewriteRule ^example/(?!foo|bar)/?$ target.php?id=$1 [NC,QSA,NE,L]
RewriteRule ^example/(?!(foo|bar))/?$ target.php?id=$1 [NC,QSA,NE,L] But trying to make it a one-liner:Don’t try. Putting a negative into the body of a RewriteRule is, at best, asking for trouble.
RewriteCond %{REQUEST_URI} ^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} ^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} ^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} ^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} ^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} ^/\.well-known/pki-validation/(?:\ Ballot169)? Target should always start with / in an internal rewrite.
What’s the [NE] flag for? There's nothing in the [-\w] group--which incidentally is more safely expressed as [\w-] with the hyphen last--that could possibly be affected by escaping.
And why the [NC] in the condition? Do you have a legacy of RaNdOmLy CaSeD links to /example/foo.html that you also need to exclude?
Turns out that he keeps his caps lock on all the timeCriminy. But how does this work without mod_speling (or 2.4 equivalent, if there is such a thing)? If there is a request for /FILENAME.HTML, does the server know to look for /filename.html? Is it done as a redirect or as a rewrite?
I kept [NE] to prevent it from sending var=$1%26id=$2Oh, yikes, I hadn’t considered the possibility of an ampersand. So that makes two situations where [NE] is essential. (The other, which is cited in the docs and is the only one I’ve personally used, is when you’re redirecting to a # fragment.)
Criminy. But how does this work without mod_speling (or 2.4 equivalent, if there is such a thing)? If there is a request for /FILENAME.HTML, does the server know to look for /filename.html? Is it done as a redirect or as a rewrite?
and they all rewrite to:And from there it's presumably trivial to tell the php to flatten the casing. All good, so long as no search engine goes into entrapment mode (they typically don't in this situation*) and then you'd be into Duplicate Content.
I kept [NE] to prevent it from sending var=$1%26id=$2
RewriteRule ^fun/panda\.html /fun/panda.php?animal=robot&page=panda [L]