Dmitry Ponkin
Dmitry Ponkin

Reputation: 424

.htaccess regex issue

 RewriteEngine on
 RewriteRule ^([a-zA-Z0-9]{1,3})\/([0-9])\.html$  thread.php?board=$1&thread=$2

Here is my .htaccess file. Let me explain you how it should work:

website.com/vg/1337.html => website.com/thread.php?board=vg&thread=1337

in the other words:

website.com/x/y.html => website.com/thread.php?board=x&thread=y
x - 1-3 symbols, A-z, 0-9;
y - unlimited amount of symbols, 0-9;

It does look pretty simple, but... website.com/vg/1337.html just leads me to 404.

What am I doing wrong?

Upvotes: 1

Views: 80

Answers (3)

Fredrik Pihl
Fredrik Pihl

Reputation: 45634

y is not "unlimited" in your example above, just allow one single digit. Add a star * after it (or a + for "1 or more").

Upvotes: 1

jancha
jancha

Reputation: 4967

[0-9]* or [0-9]+

missing enumerator after [0-9]. if you don't put anything, it would work for one char only

Upvotes: 1

Mark Byers
Mark Byers

Reputation: 837966

Your regular expression only matches URLs that contain a single digit, for example "5.html".

To fix it change [0-9] to [0-9]+. The plus means "one or more of the previous token".

Upvotes: 4

Related Questions