Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have:

redirect 301 /users/foo
redirect 301 /users/bar

Can I do something like?

redirect 301 ^\/users/(.+)$$1


Found a solution:

RedirectMatch users/(.+)$1 [R=301,L]

This actually redirects instead of rewriting.

Edit 2

See @Darth Android's solution with RewriteEngine which works just as well :)

share|improve this question
up vote 7 down vote accepted

Try using rewrite rules if you have apache:
RewriteEngine on
RewriteRule ^/users/(.*)$$1 [R=301,L]

Note that you will need ModRewrite installed and enabled in your apache config. Pulled from here if you need a method for IIS.

share|improve this answer
I actually wanted to redirect, not just rewrite. Appreciate the help though :) – macek Jun 21 '10 at 19:52
@macek I haven't tested it personally, but I'm under the impression that will redirect with a 301 code. I'll play around with it a bit. The [R=301,L] means to stop processing rewrite rules and issue a 301 redirect. – Darth Android Jun 21 '10 at 19:54
ah, I didn't know you could use [R=301,L] at then end of a RewriteRule. Thanks for this :) – macek Jun 21 '10 at 19:55
@macek I didn't either until about 30 seconds ago. This is why I come to this website to be entirely honest. Thanks for increasing my knowledge! :P – Darth Android Jun 21 '10 at 19:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.