Re: Regular expresions for dummies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Krist van Besien wrote:
On Jan 10, 2008 3:58 PM, Lester Caine <lester@xxxxxxxxxxx> wrote:
I'm trying to set up an AliasMatch to catch some now quite regular attempts to
find 'phpmyadmin' using a whole string of different case versions of
'phpmyadmin' and then 'phpmyadmin-(various version number strings)'

I think my starting point needs to be a nice dummy reference to writing the
necessary regular expression. Alternatively can someone who has already done
it provide me with an sample :)

Of cause what is more annoying is that my web page footer lists the tools I'm
using - and a link to the server set-up so if they looked they would know I
don't use MySQL!

Having started to get everything under control I'm spending a little time each
day checking the error log and so anything to strip garbage and just leave the
real errors will be useful. I have a couple of other similar AliasMatch
entries to create but http://perldoc.perl.org/perlre.html is going over my head :(

http://perldoc.perl.org/perlretut.html would be a better place to start :-)
I've found that one now as well and it's a bit more readable.

The question remains what you want to achieve. Currently all these
requests for phpmyadmin get a 404 returned I presume. With a
AliasMatch you can have these requests return something else, at the
expense of extra work for you and your server. Why would you want
that?
It was a simple example.
The other bits I want to trap relate to legacy links from a windows server, so the case is somewhat random.

Anyway you could use something like:

AliasMatch (?i)^/phpmyadmin    /there-is-no-phpmyadmin-here-so-bugger-off.html

That is it exactly. Although I'll probably do a 'get a decent database' page :)

(?i) makes the match case insensitive.
^ anchors your regular expression to the start of the url.

That is the poke I needed. Actually I was making things more complex than they needed to be - thinking down the lines of preg_.. and having to wrap the expression.

The rest is what you want to match, where you don't need to match the
whole string, just enough so it's unique. /phpmyadmin will match
/PHPMyAdmin, /PHPMyAdmin-someversion etc...

TA

--
Lester Caine - G8HFL
-----------------------------
Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://home.lsces.co.uk
MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Firebird - http://www.firebirdsql.org/index.php

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux