user2250471
user2250471

Reputation: 1112

how can you specify the length of an hatccess rewrite

If I'm doing a rewrite, is there a way to distinguish between the string length, like if it's 2 characters, it goes to one page, but if it's 3 or more, it goes to another one?

RewriteRule ^([a-zA-Z0-9]+)/?$ two-characters.php?u=$1 [QSA] // 2 char
RewriteRule ^([a-zA-Z0-9]+)/?$ three_plus_characters.php?u=$1 [QSA,L] // 3+ char

Upvotes: 1

Views: 585

Answers (1)

Panama Jack
Panama Jack

Reputation: 24478

You can try your rule this way.

RewriteRule ^([a-zA-Z0-9]{2})/?$ two-characters.php?u=$1 [QSA] // 2 char
RewriteRule ^([a-zA-Z0-9]{3,})/?$ three_plus_characters.php?u=$1 [QSA,L] // 3+ char

Upvotes: 2

Related Questions