Forum Moderators: phranque

Message Too Old, No Replies

Permanent redirect of directory to a new domain

directory redirection to new domain

         

Mahavir

3:21 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



Hi All,

I have a website and I have a directory in it which is related to travel only.I buy a new domain and I want to redirect this directory to my new domain without losing my search rankings. What's the best method.

This is what I want to accomplish,

www.mysite.com/mydirectory(old domain) ---> www.mydirectory.com (new domain)

How can i use mod rewrite using htaccess so that i can completely redirect directory and all files under it to new domain.

Thankx.

jdMorgan

4:29 pm on Apr 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post any code you've already tried as a basis for discussion.

See our forum charter and the documents cited therein, and the posts in our forum library if you need help getting started.

Thanks,
Jim

Mahavir

5:11 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



I haven't tried anything yet but looking forward for help from you guys.

Mahavir

2:57 pm on Apr 11, 2008 (gmt 0)

10+ Year Member



This is what I thing might work..please check ..

RewriteEngine On

RewriteCond %{HTTP_HOST} ^.*mysite\.com\mydirectory$ [NC]
RewriteRule ^(.*)$ http://www.mydirectory.net/$1 [R=301,L]

[edited by: jdMorgan at 3:03 am (utc) on April 12, 2008]
[edit reason] de-linked [/edit]

jdMorgan

3:02 am on Apr 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put this code in www.mysite.com/mydirectory/.htaccess

RewriteCond %{HTTP_HOST} mysite\.com\mydirectory [NC]
RewriteRule (.*) http://www.mydirectory.net/$1 [R=301,L]

If you want to put the code into www.mysite.com/.htaccess instead, then the code needs to change:

RewriteCond %{HTTP_HOST} mysite\.com\mydirectory [NC]
RewriteRule ^mydirectory/(.*) http://www.mydirectory.net/$1 [R=301,L]

Jim

Mahavir

10:48 am on Apr 12, 2008 (gmt 0)

10+ Year Member



Thanks very much Jim, will you please check the following, can I use this also,

RewriteEngine on
RewriteBase /
RewriteRule ^mydirectory/(.*) http://www.mydirectory.com/$1 [R=301,L]

[edited by: Mahavir at 10:56 am (utc) on April 12, 2008]

[edited by: jdMorgan at 12:54 pm (utc) on April 12, 2008]
[edit reason] de-linked [/edit]

jdMorgan

12:54 pm on Apr 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure. You can certainly change .net to .com if you like.

However, you can only delete the RewriteCond line if mysite.com and mydirectory.com are hosted on separate servers, or in completely-separate accounts on one server.

It's not clear from what you've posted whether these domain are hosted together or apart, though.

"RewriteBase /" is the default. You don't need to use that line, unless you need to override a previous RewriteBase directive in this file.

Jim