1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Multiple Domains...

Discussion in 'Apache' started by digitalpoint, Mar 4, 2004.

  1. #1
    Here's a little tip for people using Apache with multiple domains pointed to a single site (even if it's just www.yourdomain.com and yourdomain.com). This can be used within your apache (or site) conf file on the server (changing the items to work with your domain/IP address of course).

    <VirtualHost 192.168.1.1>
    ServerName [url]www.yourdomain.com[/url]
    ServerAlias [url]www.anotherdomain.com[/url] yourdomain.com
    RewriteEngine on
    RewriteCond %{HTTP_HOST}                !^192.168.1.1(:80)?$
    RewriteCond %{HTTP_HOST}                !^www.yourdomain.com(:80)?$
    RewriteRule ^/(.*)                      http://www.yourdomain.com/$1 [L,R=301]
    </VirtualHost>
    Code (markup):
    What that will do is redirect any request within the domains defined in ServerAlias to the correct location within the main domain using a search engine friendly 301 redirection.

    This is nice because you don't have to have tons of rewrites, and it also makes search engines happy because you aren't replicating content.

    - Shawn
    SEMrush
     
    digitalpoint, Mar 4, 2004 IP
    SEMrush
  2. SEOGulper

    SEOGulper Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    So... what if we are on a shared server, and have no access to the config file or the root directory?

    Can this be done with the htaccess file in the home directory of a shared server?
     
    SEOGulper, Jun 1, 2004 IP
  3. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,159
    Likes Received:
    2,582
    Best Answers:
    457
    Trophy Points:
    710
    Digital Goods:
    29
    #3
    Yes, you should be able to do it within the .htaccess file as well. Although I've never done it at that level myself, so I can't offer an example. But pretty much if you just use the RewriteCond and RewriteRule lines, I think you would be okay.
     
    digitalpoint, Jun 1, 2004 IP
  4. Owlcroft

    Owlcroft Peon

    Messages:
    645
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #4
    In a word, Yes.

    My own local .htaccess files deal with a more restricted case, that of just the presence or absence of the leading "www.". They typically look like this:

    RewriteCond %{HTTP_HOST} www.seo-toys.com
    RewriteRule ^(.*) http://seo-toys.com/$1 [L,R=301]
    The ones presented in the post above are more general in scope, and essentially, as I understand it, redirect any call that is not exactly what you want to the one that is exactly what you want.

    That is, the conditions--

    !^192.168.1.1:)80)?$
    !^www.yourdomain.com:)80)?$​
    --specify that anything that is not Port 80 on either 192.168.1.1 or www.yourdomain.com is something to rewrite to:

    http://www.yourdomain.com/$1​
    (where the $ stuff means plug in whatever follows).
     
    Owlcroft, Jun 1, 2004 IP
    ViciousSummer likes this.
  5. al2six

    al2six Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #5
    I want to use this on my shared server... are those two lines of code all I have to add to my .htaccess file? Or is there more? sorry for my ignorance, I've never really done much stuff like this
     
    al2six, Jun 15, 2004 IP
  6. LucidNet

    LucidNet Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i have access to my conf file but have already done the htaccess redirection instead?

    Would you say it is better for me to move the redirection to the conf file? and why?

    al2six.... i just did that to my htaccess and it worked fine. Just them two lines of code
     
    LucidNet, Jun 15, 2004 IP
  7. al2six

    al2six Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #7
    It doesn't seem to be working for me...
    Here is the entire contents of my htaccess file:

    RewriteCond %{HTTP_HOST} www.musicgearmaster.com
    RewriteRule ^(.*) http://musicgearmaster.com/reviews/drums/$1 [L,R=301]

    It should take you to the nonexistant folder reviews/drums but it still just takes you to the index page.

    Any ideas why it isn't working?
     
    al2six, Jun 15, 2004 IP
  8. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,220
    Likes Received:
    778
    Best Answers:
    0
    Trophy Points:
    0
    #8
    We have two domains per site, one is our own URL and one is a subfolder of the big shopping portal who provide our ecommerce solution. I get the impression (Shawn's Tool confirms it) that Google likes the pages in the subfolder better than those in our own URL.

    Is there any reason why Google would prefer pages from a domain with thousands of pages over the exact same page on a domain with just a few hundred?

    Amazon seems to appear in a lot of top 10 listings, does G take website size into account when it comes to calculating SERPs? I'm debating which one to choose if we do want to redirect the other...

    Any ideas?
     
    T0PS3O, Jun 15, 2004 IP
  9. al2six

    al2six Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #9
    can anyone help?
     
    al2six, Jun 17, 2004 IP
  10. john_loch

    john_loch Rodent Slayer

    Messages:
    1,294
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    138
    #10
    Remember to enable the rewrite engine in the first place.. (you'll notice the line in Shawns original post).. try:
    --snip--
    RewriteEngine on

    RewriteCond %{HTTP_HOST} www.musicgearmaster.com
    RewriteRule ^(.*) http://musicgearmaster.com/reviews/drums/$1 [L,R=301]
    --snip--

    Cheers,
    JL. :)
     
    john_loch, Jun 17, 2004 IP
  11. al2six

    al2six Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #11
    thanks! that worked. however it didn't do quite what I want it to do...
    I have more than one domain on that server. Each domain is for a seperate site and should point to a folder containing the content for that site.

    so when you type in www.musicgearmaster.com, i want it to take you to www.musicgearmaster.com/reviews/index.php. But if i use the following...

    RewriteCond %{HTTP_HOST} www.musicgearmaster.com
    RewriteRule ^(.*) http://musicgearmaster.com/reviews/$1 [L,R=301]

    Then if you type in the exact filename of a page (ie www.musicgearmaster.com/reviews/index.php) it will try to take you to www.musicgearmaster.com/reviews/reviews/index.php

    anyone have a solution for this?
     
    al2six, Jun 17, 2004 IP
  12. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,159
    Likes Received:
    2,582
    Best Answers:
    457
    Trophy Points:
    710
    Digital Goods:
    29
    #12
    Take off the "reviews/" part of your RewriteRule.
     
    digitalpoint, Jun 17, 2004 IP
  13. al2six

    al2six Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #13
    But the index page for the site is in the reviews folder. If I take off the reviews, when you type in the domain, it will take you to index.php (which is the index for another site on the server) instead of reviews/index.php which is the correct index page.
     
    al2six, Jun 17, 2004 IP
  14. flawebworks

    flawebworks Tech Services

    Messages:
    991
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    78
    #14
    Will doing this; as you demonstrate:

    RewriteCond %{HTTP_HOST} www.seo-toys.com
    RewriteRule ^(.*) http://seo-toys.com/$1 [L,R=301]

    Cause google to change any backlinks going to www to end up with the non-www backlinks it has picked up?

    Do I even make sense?:O

    In other words: the majority of my backlinks go to domainname.com as opposed to www.domainname.com - I have 5 or 6 strays that I would really like to show up under the domainname.com backlinks.

    Thanks for the above string. I've been trying for 2 days to get a 301 redirect to work the way I want it to.

    Regards;

    Flawebworks
     
    flawebworks, Jun 21, 2004 IP
  15. flawebworks

    flawebworks Tech Services

    Messages:
    991
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    78
    #15
    Got my answer:

    forums.seochat.com/showthread.php?p=90130
     
    flawebworks, Jun 21, 2004 IP
  16. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #16
    I made an error and only copied the 4 Rewrite lines, leaving off the ServerAlias line.

    I already had a similar ServerAlias line, but one with only one argument in it. I also have a ServerName line.

    My code, therefore, looks like this:

    
    ServerName www.internet-search-engines-faq.com
        ServerAlias internet-search-engines-faq.com
        RewriteEngine on
        RewriteCond %{HTTP_HOST}                !^216.17.194.115(:80)?$
        RewriteCond %{HTTP_HOST}                !^www.internet-search-engines-faq.com(:80)?$
        RewriteRule ^/(.*)                      http://www.internet-search-engines-faq.com/$1 [L,R=301]
    
    Code (markup):
    Works just the same with the slightly different syntax. :)
     
    Will.Spencer, Aug 29, 2004 IP
  17. danpadams

    danpadams Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Will,
    Is the second version of the code you last posted in this thread the .htaccess equivalent of the code above that would be from an httpd.conf file?
     
    danpadams, Mar 24, 2005 IP
  18. clasione

    clasione Well-Known Member

    Messages:
    2,358
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    198
    #18
    ok - I can't seem to get this to work......

    Give me an example based on the following senario....

    All pages of .net are moving to .com

    So I need an example using all pages of:

    www.from.net
    from.net

    redirect to:

    www.destination.com
     
    clasione, Nov 1, 2005 IP
  19. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #19
    Heck, this is more complex than you need for that.

    Just put this one line in the .htaccess file for your .net domain:

    Redirect 301 /             http://www.destination.com/
    Code (markup):
     
    Will.Spencer, Nov 2, 2005 IP
  20. elrayjones

    elrayjones Guest

    Messages:
    99
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Thanks this is just what I was looking for :)
     
    elrayjones, Nov 2, 2005 IP