Forum Moderators: phranque
I'm new here and did a quick search, but could not find an answer to my problem.
I am trying to redirect all the pages from one domain to another. What has happened is that the site was originally built and hosted with a .cc domain. The .com version of the domain just came available and we want all the pages from the .cc domain to redirect to the .com domain.
We have set up a separate hosting account for the .cc site and I implemented the following re direct:
RedirectMatch 301 ^(.*)$ http://www.example.com
It is working in that pages to redirect, but they only redirect to the home page, and not their equivalent on the .com site.
For example I want to redirect www.example.cc/pageone to www.example.com/pageone.
I was under the impression that the above command would accomplish this.
I have also tried inputing each individual page into the .htaccess file and they still all redirected to the home page using the standard 301 redirect command. However, it does work if I just place one line for one page in there...
Can anyone provide any insight to why this may be happening - did I use the RedirectMatch command incorrectly?
Thanks so much!
Raerae
Use any of the following to redirect to the new domain while retaining the local URL-path:
RedirectMatch 301 (.*) http://www.example.com[b]/$1[/b] Redirect 301 / http://www.example.com/ RedirectPermanent / http://www.example.com/ When using RedirectMatch, enclosing a pattern or subpattern in parentheses creates a back-reference. The value matching the (sub)pattern can then be "back-referenced" in the new URL by number, with the number corresponding to back-references numbered according to the left-parenthese count. If the (sub)pattern's value is not back-referenced, it is simply dropped.
When using the Redirect directive, any part of the URL-path not specified in the prefix-match on the left is appended to the URL specified on the right.
So, any of the examples above will do what you need.
Jim