Rewrite rule validation

I want to be able to use references such as
http://www.domain.com/team/ab
instead of
http://www.domain.com/team.php?id=ab
where id may be 2 or 3 alpha or 2 alpha + 1 numeric digits

Can anyone tell me what validation I need to use in the following directive please?

RewriteRule ^/team/([a-z]+)/?$ /team.php?id=$1 [PT,L]

Thanks

To check for two or three alpha digit you need [a-z]{2,3} , or [a-zA-Z]{2,3} if you want to include capitals.
I don’t see a digit in your example so I suppose it’s optional? In that case that would be [0-9]?

So:


RewriteRule ^/team/([a-z]{2,3}[0-9]?)/?$ /team.php?id=$1 [PT,L]

By the way, if you’re not using mod_alias or any other module that also works on an URI, you can drop the [PT]
And, are you on Apache 1.x? If not, change ^/ at the start of the rule with just ^ – remove the /

Many thanks, Scallio. It’s Apache 2.2.11 and I assume it’s using mod_alias as I can use the Redirect directive.

G :slight_smile: