Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

We are trying to create a set of 301 redirects where the exact string from the old URL is also present in the same position in the new URL. See the example below:



We've tried a standard 301 redirect like this:

Redirect 301 /foobar$

This doesn't work and causes a 404:

File does not exist: /home/domain/public_html/foobar

Should we be looking at rewrite rules instead or can this be fixed by just adjusting the 301 rule?


share|improve this question

migrated from May 3 '12 at 12:50

This question came from our site for professional and enthusiast programmers.

When you enter in browser does it open a valid page? – anubhava May 2 '12 at 12:45
yes it does - that is the valid new URL – seengee May 2 '12 at 13:03
up vote 1 down vote accepted

You need to use the RedirectMatch in mod_alias i.e:

RedirectMatch 301 /foobar$


share|improve this answer
i don't need the variable from the right so not sure that is necessary. Either way that creates a redirect loop in Chrome – seengee May 2 '12 at 13:24
soory - only dawned on me that the domains were the same. Will edit – William Greenly May 2 '12 at 13:55
ok, thats got it. thanks! – seengee May 2 '12 at 14:04

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.