Using Htaccess To Redirect Domain?

I have domain A and B, and I want redirect domain A to domain B.

For example:

mywebsite.com/post/index/555

redirect to

mynewwebsite.com/post/index/555

I have tried many htaccess example.

It only redirect me to the home page, cant redirect me to same page.

Even I set the htaccess non-www redirect to www is also have this problem.

Is it the URL rules problems? How can I do it?

Thanks!

Try in your .htaccess




RewriteEngine On

RewriteRule ^/post/index/\d+  http://mynewwebsite.com/post/index/$1



Try in your .htaccess




RewriteEngine On

RewriteRule ^/post/index/\d+  http://mynewwebsite.com/post/index/$1



Thanks for your quick reply!

In fact, I have a few domains and all domain already set the alias to domain B.

Now is showing the domain B content, but the url still is domain A url.

I want change to domain B url.

So, I want set the htaccess in domain B server.

If the domain not equal domain B, redirect to domain B.

And the page not only post/index, I have many other different pages. Any ideas?