3

I have recently moved a site to a new domain, and at the old domain, I created a .htaccess file that includes one line of code:

RedirectMatch 301 ^/(.*) http://newdomain.com/$1

The goal, of course, is to set 1:1 redirects for the entire site for anyone trying to access old links to the site.

This works perfectly unless the user includes "www." when they enter a URL for the old domain. In that case, they are not redirected.

I'm sure this has something to do with my ^/, but I'm not sure what, as I did not think you could specify any rules regarding anything preceding the initial / following the domain.

Does anyone know why this does not work when the user types in "www." as part of the URL on the old domain? And can you please tell me what I can do to fix this and make it redirect properly as it does otherwise?

Thank you for your help.

Edit: I was mistaken. The problem is when the person on this one particular computer includes "www."--not "http://" as I originally thought. Sorry for the oversight.

3
  • One thought I just had. Is it possible that this user's browser had the IP address and header information cached rather than the URL, and that is causing the problem?
    – rrr45
    Sep 25, 2014 at 17:51
  • Is there separate configuration for the www hostname. A separate VirtualHost directive for example? Sep 25, 2014 at 18:20
  • No. Literally the only things in public_html on the old domain are the one-line .htaccess file and an empty cgi-bin directory.
    – rrr45
    Sep 25, 2014 at 19:21

2 Answers 2

1

Here is the one simple answer for your issue. Just Sign in into your domain panel and redirect the new domain name instead of old domain name.

In this case what happened is if anyone open the old website it automatically redirect to the new domain website.

0

Try plain old Redirect instead. Its behavior is to set up the one to one match you are looking for. The following redirects every page on your current domain to the corresponding page on your new domain.

Redirect 301 / http://newdomain.com/
2
  • It's still not working. Seems very strange. I also realized that it "www." is apparently the problem--not "http://". Is it possible for someone to change the topic title?
    – rrr45
    Sep 25, 2014 at 17:47
  • Yes. Use the "edit" link. Sep 25, 2014 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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