Domain redirect issues (.htaccess)

Discussion in 'Site & Server Administration' started by rj23, Jul 3, 2007.

  1. #1
    Hi,

    We have two domains - abc.com and xyz.com

    abc.com is a domain that we started off with. But now the main domain
    is xyz.com

    Our site administrators have mapped both the domains to the same ip address. So essentially there is only one folder which has all the files pertaining to the website.

    If anyone types in abc.com they go to the same website as xyz.com.

    abc.com and xyz.com are the same.

    The only problem is that abc.com does not resolve into xyz.com on the address bar.Therefore the search results are still reflecting abc.com in their index.xyz.com is not receiving any listings in search engines.

    I know that I have to implement .htaccess, but I do not have two separate directories for the sites. So if i want a 301 redirect for abc.com, where do I place the .htaccess file?

    I do not want to remove the earlier domain completely as it has a lot of valuable back links.

    We have an apache web server.

    Any help on this would be greatly appreciated.

    Thanks so much.

    Best regards
    RJ
     
    rj23, Jul 3, 2007 IP
  2. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Add a .htaccess file with the following code in your xyz.com root folder. It will solve your problem.


    RewriteEngine On
    RewriteCond %{HTTP_HOST} . 
    RewriteCond %{HTTP_HOST} !^www\.xyz\.com [NC] 
    RewriteRule (.*) http://www.xyz.com$1 [R=301,L]
    Code (markup):
     
    bouncer69, Jul 3, 2007 IP
    agnivo007 likes this.
  3. rj23

    rj23 Banned

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks.
    Will implement that and let you know how it goes.

    Regards
    RJ
     
    rj23, Jul 3, 2007 IP
  4. agnivo007

    agnivo007 Peon

    Messages:
    4,290
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think some more code is required if www isn't used.
     
    agnivo007, Jul 4, 2007 IP
  5. rj23

    rj23 Banned

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,

    It does not seem to be working:(

    Could it be becasue there are other domains also mapped to the same ip?

    There are about 4 product sites and the product domains are mapped to the the same IP. There is a java redirect in the directory which redirects that particular domain to a specific folder within the directory.

    abc.com and xyz.com are redirected to the another such specific folder within the directory.

    What I wanted was that when people type in "http://www.abc.com" the address bar automatically resolves to "http://www.xyz.com" using a 301 redirect' cause this method seems to be the most accepted method of redirect.

    Also, "http://www.abc.com" features in search results, whereas "http://www.xyz.com" does not. I guess since both the domains are reflecting the same content, search engines are giving more value to one domain.

    We want "http://www.xyz.com" to feature in the search results.


    Is there any way out?


    Thanks.

    Best regards
    Ranjana
     
    rj23, Jul 9, 2007 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    All the code above does is redirects to the same URL!! :D

    RewriteEngine On
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.abc\.com [NC]
    RewriteRule (.*) http://www.xyz.com$1 [R=301,L]

    or

    abc.com/.htaccess

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)$ http://www.xyz.com/$1/ [R=301,L]
     
    Nintendo, Jul 10, 2007 IP
  7. rj23

    rj23 Banned

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks:)
    Will try this out.
     
    rj23, Jul 10, 2007 IP
  8. cdx

    cdx Peon

    Messages:
    364
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Do I need to delete everything from the website and keep just the htaccess file ?

    What happens when someone will try to reach the old domain ?

    Thanks in advance,
    Guy.
     
    cdx, Jul 10, 2007 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #9
    You get redirected to the new domain.
     
    Nintendo, Jul 10, 2007 IP