9

If I have:

redirect 301 /users/foo http://www.example.com/profiles/foo
redirect 301 /users/bar http://www.example.com/profiles/bar

Can I do something like?

redirect 301 ^\/users/(.+)$ http://www.example.com/profiles/$1

Edit

Found a solution:

RedirectMatch users/(.+) http://www.exapmles.com/profiles/$1 [R=301,L]

This actually redirects instead of rewriting.


Edit 2

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

macek
  • 6,525

1 Answers1

13

Try using rewrite rules if you have apache:
RewriteEngine on
RewriteRule ^/users/(.*)$ http://www.example.com/profiles/$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.

Darth Android
  • 38,658