Using Htaccess To Redirect Domain?

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

For example:

redirect to

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?


Try in your .htaccess

RewriteEngine On

RewriteRule ^/post/index/\d+$1

Try in your .htaccess

RewriteEngine On

RewriteRule ^/post/index/\d+$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?