So, I've the next RegEx..

RewriteRule ^([-a-z0-9]*[A-Z\.]+.*)$ file.php?string=$1 [QSA]

The URL I would like file.php to trigger for must either have capital letters or perhaps a period inside it, then send the Hyperlink to the PHP script.

However, the issue I've is this fact script is triggering on any URL, due to the not-truly-steered clear of Period.

I have attempted getting away the time having a backslash, or two backslashes, or three... but none of them steer clear of the generic interpretation.

What shall we be held doing wrong?

Edit: For example,

RewriteRule ^([-a-z0-9]*[A-Z\\.]+[-a-z0-9\/]*)$ file.php?string=$1 [QSA]

Does not work, but

RewriteRule ^([-a-z0-9]*\\.+[-a-z0-9\/]*)$ file.php?string=$1 [QSA]

does escape it.

Edit 2: Good examples of Web addresses I wish to redirect:

  • /some-page-goes-here.html
  • /heres-Sucks/Old/Page/

And ones I do not:

  • /testing/one/two/
  • /an/actual-file.presen

EDIT 3: Old regex was:

RewriteRule ^([-a-z0-9]*[A-Z\.]+[-a-z0-9\/]*)$ file.php?string=$1 [QSA]

But while writing the publish, I up-to-date the question's regex to a specific item above.

Try:

RewriteCond %{REQUEST_URI} [A-Z] [OR]
RewriteCond %{REQUEST_URI} \.html$
RewriteRule (.*) file.php?string=$1 [QSA]

When utilizing mod_rewrite and you've got several Web addresses to complement, it is usually easier to use RewriteCond to filter after which apply your RewriteRule.

I do not think your condition could be what you believe it's: periods inside a character class are meant to mean literal periods, not "any character". If the really is the issue, in some way, then you may change [A-Z\.]+ to ([A-Z]|\.)+ however i doubt it. Several things to test:

  • what goes on should you comment out this line? does that effectively disable this redirect? otherwise, then clearly the issue is not with this particular line. :-)
  • what goes on if one makes mtss is a real HTTP redirect, by altering QSA to QSA,R? Does the destination URL seem like that which you expect? Maybe you will find some unpredicted periods or uppercase letters? (Warning: this can most likely trigger an infinite redirect loop by trying it inside a browser it'll most likely be simpler to test posting the request via port-80 Telnet to see the particular HTTP response.)

Also, your rule does not quite match the way you describe it. For instance, your rule wouldn't match a URL like a.b.c, since you only uppercase letters and/or dots to happen in one "clump" if they are separated by lowercase letters, no match will occur. Is the fact that simply because you did not wish to overcomplicate the description?