Forum Moderators: phranque

Message Too Old, No Replies

how to redirect olddomain.com to old-domain.new-domain.com

         

afthl

2:34 pm on Aug 15, 2009 (gmt 0)

10+ Year Member



Hi

I need to redirect all links from old domain to new domain
and making the old domain as a subdomain in the new domain

for example:

mysite.com/forum1
to
mysite.newsite.com/forum1

and the below points must be done:
-Users will automatically be redirected to the new domain - you don't have to inform them.
-search engines will be redirected to the new domain - and all related information will be moved to the new domain.

any suggetions?

Regards
Ayman

jdMorgan

3:01 pm on Aug 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Ayman, and welcome to WebmasterWorld!

A good suggestion would be to try a search [google.com] on WebmasterWorld for a good start.

The resources cited in our Apache Forum Charter [webmasterworld.com], and the threads in our Apache Library [webmasterworld.com] may also prove useful.

Jim

afthl

3:46 pm on Aug 16, 2009 (gmt 0)

10+ Year Member



Hi Jim

thank you for your useful advice

I will do the search now

regards
Ayman

yoyan

4:44 pm on Aug 16, 2009 (gmt 0)

10+ Year Member



I learn a lot from you . haha ,a good suggestion!

afthl

5:59 pm on Nov 23, 2009 (gmt 0)

10+ Year Member




System: The following message was spliced on to this thread from: http://www.webmasterworld.com/apache/4030216.htm [webmasterworld.com] by jdmorgan - 12:42 pm on Nov. 23, 2009 (CDT -6)


Hi everybody

i tried very hard to do it but i didn't find the right way.
this is my topic
[webmasterworld.com...]

i got this code but i think it works in opposite way:
#Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite.newdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.newdomain.com$
RewriteRule (.*)$ [yoursite.com...] [R=301,L]

i need it in opposite way , so shull i do it like this?:
RewriteCond %{HTTP_HOST} ^yournewdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yournewdomain.com$
RewriteRule (.*)$ [yoursite.newdomain.com...] [R=301,L]

is this right?

please help coze i'm not good in coding

thanking you

jdMorgan

6:44 pm on Nov 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are the two 'sites' hosted on the same server in the same filespace?

Jim

afthl

8:30 pm on Nov 25, 2009 (gmt 0)

10+ Year Member



Hi Jim,

no they are not.

so the site will stay on the current server without transfering any file.

only redirect the domain.

jdMorgan

3:09 pm on Nov 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, well that answer leaves me a bit confused...

But I suppose you could try this, which may do what you want:


# Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} mysite\.com [NC]
RewriteRule ^(.*)$ http://mysite.newsite.com/$1 [R=301,L]

Note that you may need to un-comment the "Options" line -- it may or may not be required on your server. If a request for "mysite.com/anything" does not redirect to "mysite.newsite.com/anything", then remove the "# " from the Options line, delete your browser cache, and try again.

Jim

afthl

5:47 pm on Nov 26, 2009 (gmt 0)

10+ Year Member



thank you so much Jim

i will try to explain and sorry for my weak language.
exactly like this:
mysite.com in server1
newsite.net in server2
the site ,files and everything are located in server1
we want only to redirect mysite.com/anything
to
mysite.newsite.net/anything

do I have to make a new subdomain as this "mysite.newsite.net" in server2?

shall i try the code above with this case?

thanking you
Afthl

jdMorgan

6:23 pm on Nov 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, but you will need to adjust the substitution URL in the rewriterule to point to the correct subdomain and domain on server2, install this mod_rewrite code on server1, define the mysite.newsite.net subdomain (or a wild-card subdomain) in your DNS Zone file for newsite.net, configure server2 to accept mysite.newsite.net requests and map them to the correct filespace on that server, and copy all of the 'mysite' files to that filespace on server2.

Since all requests for mysite.com will be redirected to mysite.newsite.net, you can delete all files and folders from server1 (except for the .htaccess file) after copying them to server2 -- No files on server1 will be accessible with this mod_rewrite code in place.

Jim

afthl

6:34 pm on Nov 26, 2009 (gmt 0)

10+ Year Member



but i want to keep the files and the database on server1 without coping them to server2.
i want the site to work on server1 using the domain of server2,
just redirecting the domain?

jdMorgan

6:48 pm on Nov 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm sorry, but you are asking for something other than a redirect, then.

You will need to configure both servers so that server1 is reverse-proxied to server2. This cannot be done in .htaccess, but will require modification to the server configuration files.

You will have to re-configure server1 to send the requesting IP address to server2, and server2 will have to be modified to log that information instead of the usual Request_Addr.

I suggest that for quickest/best results, you hire a local consultant to do this for you, as otherwise it may take several weeks to get it working.

Jim

[edited by: jdMorgan at 9:08 pm (utc) on Nov. 26, 2009]

afthl

6:52 pm on Nov 26, 2009 (gmt 0)

10+ Year Member



thank you so much Jim
i appreciate your replies

regards
Ayman