0

my primary domain is makemyhome.com and another one mmh.com now when a user click on the link mmh.com/about it should redirect to makemyhome.com/about.

when a user click on mmh.com/contact it should redirect to makemyhome.com/contact

right now my htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^old.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old.com [NC]
RewriteRule ^(.*)$ https://new.com/$1 [L,R=301,NC]

With the above code in htaccess doesn't work the way i want.

I need suggestion. Thanks!

Hola
  • 2,163
  • 8
  • 39
  • 87

1 Answers1

0

The above answer is almost correct. By adding the parameter %{REQUEST_URI} to the destination request your full request URI will also be redirected. For example: http://old.com/somepath/?some_get_param=some_get_val ==> https://new.com/somepath/?some_get_param=some_get_val

RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com
RewriteCond %{HTTP_HOST} ^www.old.com
RewriteRule ^ https://new.com%{REQUEST_URI}
ARN
  • 679
  • 7
  • 15
  • While this might answer the authors question, it lacks some explaining words and links to documentation. Raw code snippets are not very helpful without some phrases around it. You may also find [how to write a good answer](https://stackoverflow.com/help/how-to-answer) very helpful. Please edit your answer. – hellow Sep 12 '18 at 08:28