I’d like to redirect: http://site.com/FOO/BAR/BAZ
to http://site.com/FOO/NEW/BAZ
so, subsitute the second segment in my URL with a new one.
ideally I’d like to use HTACCESS and a 301 as these pages have permanently moved.
The URL structure will not change. Ideally there won’t be a query string, but doesn’t matter too much is there is.
thanks
8EDIT* – I should clarify and say that “BAR” is not a wildcard – it is one word. the real life example is:
old Links: site.com/events/details/XXX
new links: site.com/events/VIEW/xxx
I don’t want: site.com/events/add-new
to redirect. JUST if the second segment equals “details” in my case.
further clarification
sorry haven’t been exactly clear.
Existing URL: site.com/events/details/%wildcard%
should redirect to site.com/foo/view/%wildcard%
but nothing else.
What about this one?
EDIT: Not sure, but you may need to pass the whole address, here’s another sample of code:
2nd edit: Here’s the final solution. I’ve tried it today on a shared hosting and it worked well.
The only difference is that the last example contains a slash (
/) at the end of the new path.