0

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:

Old URL

http://www.domain.com/foobar

New URL

http://www.domain.com/foobar/i55

We've tried a standard 301 redirect like this:

Redirect 301 /foobar$ http://www.domain.com/foobar/i55

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?

Thanks.

2
  • When you enter http://www.domain.com/foobar/i55 in browser does it open a valid page?
    – anubhava
    May 2, 2012 at 12:45
  • yes it does - that is the valid new URL
    – robjmills
    May 2, 2012 at 13:03

1 Answer 1

1

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

RedirectMatch 301 /foobar$ http://www.domain.com/foobar/i55

EDITED BASED COMMENT

2
  • i don't need the variable from the right so not sure that is necessary. Either way that creates a redirect loop in Chrome
    – robjmills
    May 2, 2012 at 13:24
  • soory - only dawned on me that the domains were the same. Will edit
    – William Greenly
    May 2, 2012 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .