transfer from example.com to www.example.com

Discussion in 'Site & Server Administration' started by ma3hd, Jun 25, 2007.

  1. #1
    Hello my dears ...

    i really have problem to transfer any vistor which browsing my site with daomin such that example.com ..i want to use www.example.com all times ...

    i try this line in httaccess
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com [NC] 
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    
    PHP:
    and work good for main page ...but i have forumes and i install vbseo ...and this lines makes forums down and browsing failed...

    so ant method to do that well with vbseo.
     
    ma3hd, Jun 25, 2007 IP
  2. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine On
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

    Use this one there shouldn't have any problem. But if you use subdomain it will make problem. Give me your URL to see.
     
    bouncer69, Jun 25, 2007 IP
  3. ma3hd

    ma3hd Active Member

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    thanks dear for help but the problem still go...

    my forum use vbseo and make a wrong with my code and your code...

    any code alse without rewrite mode ?
     
    ma3hd, Jun 26, 2007 IP
  4. ma3hd

    ma3hd Active Member

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    any suggests else please
     
    ma3hd, Jun 27, 2007 IP
  5. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It will work fine with vbseo. I'm using without any problem.

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

    Make sure it's above your other RewriteCond's in the file, but under the RewriteEngine On.


    If you need more help send me your htaccess file i'll fix it for you.
     
    bouncer69, Jun 28, 2007 IP
  6. ma3hd

    ma3hd Active Member

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #6
    thanks alot Mr. bouncer69 ...

    I know this lines from vbseo already but ..

    my forum located in www.example.com/vb

    and my .htaccess here
    
    ExpiresActive On
    ExpiresByType image/gif "access 1 week"
    ExpiresByType image/jpg "access 1 week"
    ExpiresByType image/jpeg "access 1 week"
    ExpiresByType image/png "access 1 week"
    ExpiresByType text/css "access 1 week"
    ExpiresByType text/js "access 1 week"
    ExpiresByType application/x-shockwave-flash "access 1 week"
    ExpiresByType application/x-javascript  "access 1 week" 
    
    <IfModule mod_security.c>
        SecFilterEngine Off
        SecFilterScanPOST Off
    </IfModule>
    RewriteEngine On
    RewriteRule ^(sitemap.*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    
    RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} (admincp|modcp|clientscript|cpstyles|images)/
    RewriteRule ^(.*)$ $1 [L]
    
    RewriteCond %{QUERY_STRING} !vbseourl=
    RewriteCond %{REQUEST_FILENAME} !chat
    RewriteRule ^(.*\.php)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteRule ^$ vbseo.php?vbseourl=index.php [L]
    RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    
    PHP:
     
    ma3hd, Jul 4, 2007 IP
  7. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi,

    It is very simple. Use the following code after RewriteEngine On. Your .htaccess file must be in your forum directory.

    RewriteCond %{HTTP_HOST} !^www\.example.\.com 
    RewriteRule (.*) http://www.example.com/vb/$1 [R=301,L]
    RewriteBase /vb/
    Code (markup):
    If you do not want to use your main directory for other purpose you can redirect to your forum with another .htaccess in the root directory.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.example\.com
    RewriteRule (.*) http://www.example.com/vb/$1 [R=301,L]
    RedirectMatch permanent ^/$ http://www.example.com/vb/
    RewriteBase /
    Code (markup):
    I hope this will help you. It is tested with my forum and working 100%
     
    bouncer69, Jul 4, 2007 IP
  8. ma3hd

    ma3hd Active Member

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #8
    thanks alot my dear ..i will try and let you know :)
     
    ma3hd, Jul 7, 2007 IP
  9. ma3hd

    ma3hd Active Member

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #9
    Hello sir..

    after i put you fist code
    
    RewriteCond %{HTTP_HOST} !^www\.example.\.com 
    RewriteRule (.*) http://www.example.com/vb/$1 [R=301,L]
    RewriteBase /vb/
    
    PHP:
    my forum is down and the link in my brows displathat :

    
    http://www.example.com/vb//home/user/public_html/vb
    
    PHP:
    i hope to find a good soultion...

    thanks for your help
     
    ma3hd, Jul 7, 2007 IP
  10. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Hi,

    Please remove the . after example. Typing mistake.

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

    and

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.example\.com
    RewriteRule (.*) http://www.example.com/vb/$1 [R=301,L]
    RedirectMatch permanent ^/$ http://www.example.com/vb/
    RewriteBase /
    Code (markup):
     
    bouncer69, Jul 7, 2007 IP
    ma3hd likes this.
  11. ma3hd

    ma3hd Active Member

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #11
    thanks alot my dear ...

    no it work good....

    :)
     
    ma3hd, Jul 7, 2007 IP