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 5 of 5

Redirecting the xxx.com to www.xxx.com

This is a discussion on Redirecting the xxx.com to www.xxx.com within the General Discussion forums, part of the vBSEO SEO Plugin category; Hi, I noticed today that my website can be visited via both www and without www url. Code: RewriteCond %{HTTP_HOST} ...

  1. #1
    Senior Member NeutralizeR's Avatar
    Real Name
    Mavi KARANLIK
    Join Date
    Feb 2006
    Location
    Ankara/TÜRKİYE
    Posts
    300

    Question Redirecting the xxx.com to www.xxx.com

    Hi,

    I noticed today that my website can be visited via both www and without www url.

    Code:
    RewriteCond %{HTTP_HOST} !^www\.msxlabs\.org
    RewriteRule (.+) http://www.msxlabs.org%{REQUEST_URI} [R=301,L]
    
    It's redirecting the file requests to www version but i want to disable direct msxlabs.org accessing.

    Example:
    msxlabs.org/legend.php is redirected to www.msxlabs.org/legend.php

    Domain access:
    msxlabs.org - www.msxlabs.org

    What's wrong or missing?

    Btw, vbseo.com is redirected to www.vbseo.com

    Apache 2.2.6 (PHP 5.2.5)

  2. #2
    Senior Member
    Real Name
    Keith Cohen
    Join Date
    Jul 2005
    Location
    Raleigh, NC USA
    Posts
    6,147
    What is the entire contents of the .htaccess in the root of the site?

    The lines you need would be:

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

  3. #3
    Senior Member NeutralizeR's Avatar
    Real Name
    Mavi KARANLIK
    Join Date
    Feb 2006
    Location
    Ankara/TÜRKİYE
    Posts
    300
    Quote Originally Posted by Keith Cohen View Post
    What is the entire contents of the .htaccess in the root of the site?

    The lines you need would be:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.msxlabs\.org
    RewriteRule (.*) MsXLabs Hi-Tech Forum - MaviKaranlik.com: “Karanl???n Mavi Yüzü...” [L,R=301]
    Code:
    <Directory /home/msxorg/public_html>
    Options All -Indexes
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.msxlabs\.org
    RewriteRule (.+) http://www.msxlabs.org%{REQUEST_URI} [R=301,L]
    RewriteCond %{HTTP_REFERER} !^http://www.msxlabs.org/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.msxlabs.org$      [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp|swf|mp3|mpeg|mpg|ram|rm|wma|wav|asx|wmv|avi|mov|zip|rar|exe)$ http://www.msxlabs.org [NC,R,L]
    RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ forum/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    #ErrorDocument 404 /forum/ [R=301,L]
    </Directory>
    
    <Directory /home/msxorg/public_html/forum>
    Options All -Indexes
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.msxlabs\.org
    RewriteRule (.+) http://www.msxlabs.org%{REQUEST_URI} [R=301,L]
    RewriteCond %{HTTP_REFERER} !^http://www.msxlabs.org/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.msxlabs.org$      [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp|swf|mp3|mpeg|mpg|ram|rm|wma|wav|asx|wmv|avi|mov|zip|rar|exe)$ http://www.msxlabs.org [NC,R,L]
    RewriteCond %{QUERY_STRING} !vbseourl=
    RewriteCond %{REQUEST_URI} !(admineu/|modmsx/|chat|cron)
    RewriteRule ^(.*\.php)$ vbseo.php?vbseourl=$1 [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !\.(jpg|gif)$
    RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1 [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !^(admineu|modmsx|clientscript|cpstyles|images)/
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1 [L,QSA]
    </Directory>
    
    <Directory /home/msxorg/public_html/forum/tags>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^(.+)/([0-9]+)/$ index.php?tag=$1&page=$2 [NC,QSA,L]
    RewriteRule ^(.+)/$ index.php?tag=$1 [NC,QSA,L]
    </Directory>
    
    Ok, we'd updated the related lines in the past because of some issues and now it's working with your advise.

  4. #4
    Member
    Real Name
    Gary Mullins
    Join Date
    Jan 2006
    Location
    Nashville, TN
    Posts
    67
    When I tried to use that same code you suggested for redirection it didn't work right in my case. This is what I put in my .htaccess file:

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

    As you can see, I want to forward requests for pimprig.com to pcapex.com. I also have a bunch of subdomains I need to do this for as well. However, when I used those lines of code in my .htaccess file and try to access my site at any url, it displays a Red Hat Linux default test page?! Any other ideas?

    EDIT // I uncommented the rewrite rules for the forum and that subdomain now works great. Anyone trying to go to a url at forums.pimprig.com are forwarded to the same URL at forums.pcapex.com. Why in the world won't it work for the root domain?
    Last edited by GlitterKill; 11-25-2007 at 05:27 PM.

  5. #5
    Senior Member
    Real Name
    Keith Cohen
    Join Date
    Jul 2005
    Location
    Raleigh, NC USA
    Posts
    6,147
    It should be:

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


    That will redirect anything that is NOT www.pcapex.com to www.pcapex.com. The ! means NOT.

Similar Threads

  1. Sitemap links in footer redirecting
    By Dave Hybrid in forum Troubleshooting
    Replies: 5
    Last Post: 05-30-2007, 10:43 AM
  2. vbseocp.php redirecting to itself?
    By Boliga.dk in forum Troubleshooting
    Replies: 1
    Last Post: 03-17-2007, 10:19 AM
  3. Redirecting a Url
    By cathiejones in forum General Discussion
    Replies: 1
    Last Post: 07-27-2006, 05:41 PM
  4. The page isn't redirecting properly
    By creativepart in forum Troubleshooting
    Replies: 3
    Last Post: 07-21-2006, 02:59 PM