BazZy
BazZy

Reputation: 2459

.htaccess exact url redirect

I have two web-sites: example.com and yyy.com

They both have similar web apps, but on different servers. I want to make Apache redirect all path requests to example.com exactly the same way to yyy.com.

For example:

1. Request:     example.com/pages/contacts
   Redirects to yyy.com/pages/contacts
2. Request:     example.com/search?first_val=45&second_val=45
   Redirects to yyy.com/search?first_val=45&second_val=45

So, is there any way to make such .htaccess file? And if yes, how do I do this?

Upvotes: 2

Views: 778

Answers (1)

Gabriel Ross
Gabriel Ross

Reputation: 5198

Try something like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$ [OR]
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.yyy.com/$1 [R=301,L]

Upvotes: 3

Related Questions