We have redirected www.old-domain.com
to www.new-domain.com
as we are not using old site any more.
So, www.old-domain.com/whatever
redirects to www.new-domain.com/whatever
. But this causes 404 errors as we don't have those pages.
So I tried to redirect everything from old-domain to the homepage of new-domain as:
if (isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'], 'old-domain.com') !== false) {
@header("Location: http://new-domain.com/");
exit;
}
This works fine but not with query string in the url.
For example: www.old-domain/whatever/?utm=123
redirects to the www.new-domain.com/?utm=123
Note the query string is preserved in new url which I don't want.
Note that I even used meta tag & Javascript based redirection but case is still the same.
Anyway to fix the error? Really appreciate your inputs. (we are using nginx server)
Thanks Regards