Djave Djave - 1 year ago 111
Apache Configuration Question

Redirect pages which end in a nubmer

This is such a stupid question, I'm so close to solving it but regex is killing me – I'm using the JavaScript history api on various pages of a test.

Server side, I would like to redirect:


All to


So I am using

Redirect 301 /test/1 /test
Redirect 301 /test/2 /test
Redirect 301 /test/3 /test

This all works, but I would like to redirect

Redirect 301 /test/1000 /test

So, here is where I am going wrong, after some hacking, googling etc I'm using:

Redirect 301 /test/([0-9]+) /test

to replace all other lines of code, but it's totally failing. What's the line to match all
so I can redirect them all at once?

Answer Source

Redirect doesn't support regex, but RedirectMatch does: httpd://‌​ch

It would read:

RedirectMatch 301 /test/[0-9]+ /test
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download