2

I've a older site running in Apache Server which is already indexed in Google. I wish to redirect all those indexed links to my new site (As the older pages are not existing any more.)

So i wish to redirect all my sub-sub pages to my new root page

I've pages like follows

http://itdost.com/answer-now/Aerobics
http://itdost.com/answer-now/HTML
http://itdost.com/answer-now/Culture

I use the following redirect code for each one

Redirect 301 /answer-now/Engineering http://www.itdost.com/questions/
Redirect 301 /answer-now/Food http://www.itdost.com/questions/
Redirect 301 /answer-now/ASP http://www.itdost.com/questions/

But as the site structure is big, i wish to do it in a single line instead of writing a line for each redirect

Some thing like the following.

Redirect 301 /answer-now/% http://www.itdost.com/questions/

But the above code does not seems to work

  • Do you want to redirect all the different /answer-now/... pages to a single /questions/ page or does each old page have its own corresponding new page? – Tonin Mar 12 '13 at 14:55
  • 1st option is correct – 2lessons Mar 12 '13 at 16:13
4

If I understand correctly that you want to redirect all your old pages to a single new page, that following configuration directive should be all you need:

RedirectMatch 301 /answer-now/.* http://www.itdost.com/questions

See apache RedirectMatch directive docs for more info.

The Redirect directive, will always append the end of the old URL to the new one.

  • Thank you. Your solution just worked like magic. It solved many issues in my website. – 2lessons Mar 12 '13 at 16:12
  • @2lessons Can you also up vote my answer as it seems it did satisfy you? That usually is the practice on SE. Thanks! – Tonin Jun 17 '13 at 19:17
  • Up vote requires 15 reputation, still waiting for it – 2lessons Jun 19 '13 at 16:08
0

Look at the RedirectMatch directive to allow wild-carding like this.

  • meulop is correct that you need to use RedirectMatch if you want to use wildcards, but in this case no wildcard is necessary. – Andrew B Mar 12 '13 at 14:23
0

You were on the right track, but you don't need a % in the Redirect statement.

Redirect 301 /answer-now http://www.itdost.com/questions

This will catch all of the queries rooted under /answer-now, per the example in the documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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