Results 1 to 10 of 10

Redirect from www.domain.com to domain.com

This is a discussion on Redirect from www.domain.com to domain.com within the General Discussion forums, part of the vBulletin SEO Discussion category; I should know this, but I don't. I would like to be able to set up my .htaccess so that ...

  1. #1
    Senior Member
    Join Date
    Aug 2005
    Posts
    124
    Liked
    0 times

    Redirect from www.domain.com to domain.com

    I should know this, but I don't. I would like to be able to set up my .htaccess so that if somebody types www.domain.com, they are given a 301 redirect to domain.com instead.

    I'm sure it's cake, but I'm not finding what I'm looking for on google.

    Thanks,
    Amy
    Premium Support for my VBulletin Mods

  2. #2
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    Hi Amy,
    the rewrite rule will look like:
    Code:
    RewriteCond %{HTTP_HOST} ^www\.domain\.com$
    RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
    It will make a 301 redirect to the *corresponding* URL (http://www.domain.com/the-page.html => http://domain.com/the-page.html).
    By the way, usually the redirection is done in the opposite direction (thus having "www.*" as the main domain).
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  3. #3
    Senior Member
    Join Date
    Oct 2005
    Location
    Phuket, Thailand
    Posts
    194
    Liked
    0 times
    In my case, I do the opposite; non www go to www.

    If you want to do that, you can use:

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

  4. #4
    Senior Member
    Join Date
    Aug 2005
    Posts
    124
    Liked
    0 times
    Works perfectly. Thank you

    Amy
    Premium Support for my VBulletin Mods

  5. #5
    Senior Member T2DMan's Avatar
    Real Name
    Michael Brandon
    Join Date
    Jul 2005
    Location
    Auckland, New Zealand
    Posts
    360
    Liked
    0 times

    Forum accessable two ways. Need htaccess.

    How about this one:

    I have a subdomain that is accessable via the main website with the subdirectory named as the subdomain.

    ie both as
    http://www.domain.com/forum
    and
    http://forum.domain.com/

    I currently have the following, but it creates issues with vbseo:

    RedirectMatch 301 ^/forum/(.*)$ http://forum.domain.com/

    the url becomes:
    http://forum.domain.com/?vbseourl=specificforumname/


    Suggestions please.
    T2DMan
    Search engine optimize vBulletin - over 55001 views
    or Contract me to onpage SEO your forum - experience the additional SERP improvements


  6. #6
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    Hi,

    if you want to have "forum.domain.com" as the main forums location, you should move your forum files to the document root for this subdomain, define vbroot in vB admincp correspondingly and then just leave a rewrite rule in the .htaccess at the old place.
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  7. #7
    Senior Member T2DMan's Avatar
    Real Name
    Michael Brandon
    Join Date
    Jul 2005
    Location
    Auckland, New Zealand
    Posts
    360
    Liked
    0 times
    Quote Originally Posted by Oleg Ignatiuk
    Hi,

    if you want to have "forum.domain.com" as the main forums location, you should move your forum files to the document root for this subdomain, define vbroot in vB admincp correspondingly and then just leave a rewrite rule in the .htaccess at the old place.
    Sorry, a misunderstanding there. The forum is in the root of http://forum.domain.com/, however, as mentioned, it is also accessable via http://www.domain.com/forum due to the host setup for the domain.

    Obviously an unsatisfactory situation which I wish to remidy via an htaccess redirect in the http://www.domain.com root directory, or one in the 'root' directory of the forum would work as well, checking to see if it was in fact the root of the subdomain, and not the directory of the base.
    T2DMan
    Search engine optimize vBulletin - over 55001 views
    or Contract me to onpage SEO your forum - experience the additional SERP improvements


  8. #8
    Senior Member
    Real Name
    Joseph Ward
    Join Date
    Jun 2005
    Posts
    23,847
    Liked
    32 times
    Blog Entries
    9
    @T2DMan:

    Do you have a robots.txt exclusion for the /forum directory in place as a backup for now?

  9. #9
    Senior Member T2DMan's Avatar
    Real Name
    Michael Brandon
    Join Date
    Jul 2005
    Location
    Auckland, New Zealand
    Posts
    360
    Liked
    0 times

    Thanks

    Sometimes the obvious eludes. I need to consult myself once every so often . Thanks. Appreciated. But the htaccess still essential....

  10. #10
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    Ok, the problem has been solved with adding the following to the forums/.htaccess:
    Code:
    RewriteCond %{HTTP_HOST} ^www.domain.com
    RewriteRule (.*) http://forum.domain.com/$1 [R=301,L]
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


Similar Threads

  1. Redirect error
    By phkk in forum Troubleshooting
    Replies: 5
    Last Post: 04-17-2006, 03:47 PM
  2. Redirect index.php?blablablabla
    By googledave in forum Custom Rewrite Rules
    Replies: 9
    Last Post: 02-06-2006, 09:45 PM
  3. Best way to redirect when moving URLS?
    By Spitfire in forum General Discussion
    Replies: 1
    Last Post: 11-03-2005, 09:50 AM
  4. Best way to redirect my old forum to vb using 301
    By Bellinis in forum General Discussion
    Replies: 11
    Last Post: 10-29-2005, 10:03 PM
  5. Redirect Question, possibly custom rule
    By Jannefant in forum General Discussion
    Replies: 2
    Last Post: 09-09-2005, 06:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •