Mobile app version of vmapp.org
Login or Join
Megan663

: .htaccess RedirectMatch not working when *some* users include "www." in URL I have recently moved a site to a new domain, and at the old domain, I created a .htaccess file that includes one

@Megan663

Posted in: #Htaccess #Redirects

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 ^/(.*) newdomain.com/

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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Megan663

2 Comments

Sorted by latest first Latest Oldest Best

 

@Chiappetta492

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.

10% popularity Vote Up Vote Down


 

@Heady270

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 / newdomain.com/

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme