I've got a website about 2000 links, along with other site using the identical pages.

I have to understand how to do in apache the redirect in one domain towards the other one, taking into accounts that whenever the .com the page would be the same on sites

Example User request: www.mydomain.com/product1

Should redirect www.mydomain2.com/product1

It ought to be a 301 redirect

Appreciate your help

This may be easily completed with mod_rewrite:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

# redirect all requests to www.domain2.com domain
RewriteCond %{HTTP_HOST} =www.domain.com
RewriteRule .* http://www.domain2.com%{REQUEST_URI} [R=301,L]

This to become put into .htaccess in website root folder (or into Virtual Host context) for world wide web.mydomain.com. This assumes that www.mydomain.com and www.mydomain2.com take presctiption different servers / virtual hosts (quite simply, not pointing in to the same physical folder).

I actually do this inside my company constantly. Knowing using mod_rewrite, turn RewriteEngine on and employ a RewriteRule using the [R] flag:

RewriteRule www.mydomain.com/product1 www.mydomain2.com/product1 [L,R]

See this site.