Assuming that you wanted people on certain IP address’s to go to another page on your own website (example.com/websitepage) - would this be correct please?
The $ signs indicate “end of string”, whereas the ^ signs indicate “start of string”.
So if we take the third line for example, that has
^25\\.53\\.91\\.24$
That will only match one IP: 25.53.91.24, and nothing else.
Now, if you take out the ^ at the start, it will also match 125.53.91.24, 225.53.91.24, 325.53.91.24, 12.254.21.20.25.53.91.24
(Yes, I realize the last two examples aren’t valid IPs)
Analogously, if you remove the $ at the end, the expression could also match 25.53.91.241, 25.53.91.242, 25.53.91.243, 25.53.91.24.21.124.124.121, etc.
Indeed leaving out the backslash also works, but you’ve then changed the meaning from “match a dot” to “match any chacter”, since that’s what a dot does in regex. So, 56.150.186.229 will also match 56a150b186c229 for example, whereas 56\.150\.186\.229 will not.
And even though nobody has an (IPv4) IP with letters in them, it’s still faster to use the backslashes because the regular expression engine will go look for a dot specifically, instead of “anything”.
Thanks, that’s answered it completely. I obviously did wonder about the dollar sign, as I wasn’t sure if removing it, made that particular line run into the next line.
Because you’re not using it as the end of the line, but to indicate you want to match something at the end of the subject string. Two completely different things.
RewriteCond %{REMOTE_ADDR} ^25\\.53\\.91\\.24$ [OR]
^ Match at end of string
^ End of line
RewriteCond %{REMOTE_ADDR} ^25\\.53\\.91\\.24 [OR]
^ End of line
When I remove the $ the “end of line” is still there, I’ve only removed “Match at end of string”.
Does that make sense?
No, it works fine for me. Though I would get rid of the :redhot: (.*) :redhot:
It’s not “matching something”. It’s indicating how/where the regular expression engine should match. I’m afraid I can’t make it any more clear than I tried in the second post of this thread. Maybe Regex Tutorial - Start and End of String or Line Anchors will help?
Yes, it’s coded properly, and it says: if (as per the RewriteCond) the User-Agent starts with (as per ^) “Zeus”, don’t redirect anywhere (as per -) and deny access to any (as per ^.* – which I would replace with .? by the way) request (as per [F])
Sorry, didn’t understand the bit to replace? Also, what would someone see from that ua? They wouldn’t get a 403 page? Do they get some sort of message?
A RewriteRule normally redirects from one point to another
RewriteRule from to [flags]
Or, it’s a rule that rewrites URLs, hence the name
However in your rule, to is empty, which means don’t rewrite this all.
You don’t need to rewrite it, because you just want to show a “forbidden” page, not another URL.
As for what the user sees, what happened when you tried?