vBulletin 4, the most powerful community software + vBSEO 3.5, the ultimate SEO solution = Your ultimate platform for 2010 and beyond. Click below to learn more.

Results 1 to 6 of 6

http://www.domain 301 redirect to http://domain

This is a discussion on http://www.domain 301 redirect to http://domain within the General Discussion forums, part of the vBulletin SEO Discussion category; Hi guys, I have few queries I'd like to get your opinions on regarding the topic title: Would somebody mind ...

  1. #1
    Member Steve's Avatar
    Real Name
    Steve P.
    Join Date
    Aug 2005
    Posts
    35

    http://www.domain 301 redirect to http://domain

    Hi guys,

    I have few queries I'd like to get your opinions on regarding the topic title:

    Would somebody mind writing me up some rewrite rules that will transfer any users who are visiting my site from the URL http://www.domain.com to http://domain.com in a SEO safe manner? I don't know a whole lot about .htaccess and rewrite rules and all that businees, but if possible could you make sure that search engines won't have a problem following the redirect?

    I say again: I'm not the brightest buton when it comes to .htaccess and that mumbo jumbo.

    I apologise if this was posted in the wrong forum but I felt this was the closest available.

    Hope someone can help me out, I'd be eternally grateful.

    Steve

  2. #2
    Member
    Join Date
    Aug 2005
    Posts
    67

    Re: http://www.domain 301 redirect to http://domain

    This can be done via .htaccess (didn't test it, but it should work just fine):
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.mydomain\.com [NC]
    RewriteRule ^(.*) http://mydomain.com/$1 [L,R=301]
    Replace mydomain with your real domain name.

    That's it.

  3. #3
    Member
    Join Date
    Aug 2005
    Posts
    67

    Re: http://www.domain 301 redirect to http://domain

    Sorry, bad code. It should be :

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

  4. #4
    Member Steve's Avatar
    Real Name
    Steve P.
    Join Date
    Aug 2005
    Posts
    35

    Re: http://www.domain 301 redirect to http://domain

    Thanks very much SEO Report Worked a treat.

    Just curious now, how woud I go about doing the exact opposite? By this I mean 301 redirecting http://domain to http://www.domain?

    I'm starting to lean more towards keeping the www. part now, as I notice it's more common when linking to other sites. If someone could provide the code I would be eternally grateful (again). I have a good idea what to tweak in your code to create this effect but better to be safe then sorry, right?

  5. #5
    Member
    Join Date
    Aug 2005
    Posts
    67

    Re: http://www.domain 301 redirect to http://domain

    You're welcome, Steve!

    This code should 301 redirect non-www URLs to their www counterpart:

    PHP Code:
    RewriteEngine On

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

  6. #6
    Senior Member
    Real Name
    Joseph Ward
    Join Date
    Jun 2005
    Posts
    23,847
    Blog Entries
    9

Similar Threads

  1. 301 redirect not working?
    By googledave in forum Troubleshooting
    Replies: 2
    Last Post: 02-12-2006, 08:37 PM
  2. Best way to redirect my old forum to vb using 301
    By Bellinis in forum General Discussion
    Replies: 11
    Last Post: 10-29-2005, 09:03 PM
  3. Incorrect 301 redirect?
    By SEO Report in forum Bug Reporting
    Replies: 2
    Last Post: 08-25-2005, 12:14 AM
  4. 301 redirect original dynamic content
    By mediax in forum Bug Reporting
    Replies: 4
    Last Post: 07-31-2005, 02:22 PM