Redirection from one domain to another domain using htaccess

Hi,

I want to write Rewrite URL for redirection for a new website using .htaccess.

I want to redirect all the visitors of old website to new website, no changes in the URL.

old URL: www.domaina.com/my-seo-url.html
New URL: www.domainnew.com/my-seo-url.html

As you can see, there is no change in the URL except the domain name.

I want to place a rewrite rule from old website to new website using .htaccess.

Can anyone come up with a solution?

Thank you.

Regards,
Dongan

Save yourself the trouble of trying to determine whether you’re using Apache 1.x or 2.x with


RewriteEngine On
[COLOR="Blue"]# if the request is for olddomain.com ...[/COLOR]
RewriteCond %{HTTP_HOST} olddomain.com$
[COLOR="Blue"]# ... rewrite it to newdomain.com preserving the URL [COLOR="Red"]using THE ORIGINAL {REQUEST_URI}[/COLOR]
RewriteRule .? http://www.newdomain.com%{REQUEST_URI} [L,R=301]

Simplicity …

Regards,

DK


RewriteEngine On
[COLOR="Blue"]# if the request is for olddomain.com ...[/COLOR]
RewriteCond %{HTTP_HOST} olddomain.com$
[COLOR="Blue"]# ... rewrite it to newdomain.com preserving the URL using (.*) and $1[/COLOR]
RewriteRule (.*) http://www.newdomain.com/$1 [L,R=301]

:slight_smile: