Results 1 to 14 of 14

.htaccess Question RE: www and no www

This is a discussion on .htaccess Question RE: www and no www within the General Discussion forums, part of the vBSEO SEO Plugin category; Hello, My site has a .htaccess in the root which redirects calls to stop SE's thinking I have duplicate content ...

  1. #1
    Member
    Real Name
    Fred
    Join Date
    Jun 2007
    Location
    UK
    Posts
    51
    Liked
    0 times

    Post .htaccess Question RE: www and no www

    Hello,

    My site has a .htaccess in the root which redirects calls to stop SE's thinking I have duplicate content

    Code:
     
    # Rule for duplicate content removal : domain.com - Get online with a domain name and web hosting vs domain.com
    # RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
    # RewriteRule (.*)$ Website Hosting - Mysite.com [R=301,L,NC]
    I also have the VBSEO .htaccess installed part of which does the same thing

    Code:
     
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com
    RewriteRule (.*) Website Hosting - Mysite.com [L,R=301]
    The two dont seem to coexist

    This means that my main html site no longer has the redirect working :(

    Can anybody tell me how I could get both redircts working?

    Thanks

    VinylJunky

  2. #2
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,741
    Liked
    168 times
    You should remove "#" characters for rewrite rules in domain root since they are used to disable (comment out) directives.

  3. #3
    Member
    Real Name
    Fred
    Join Date
    Jun 2007
    Location
    UK
    Posts
    51
    Liked
    0 times
    Quote Originally Posted by Oleg Ignatiuk View Post
    You should remove "#" characters for rewrite rules in domain root since they are used to disable (comment out) directives.
    I added the # to stop the rewrite working because if it runs it causes problems.

    The one in my site root used to work until I activated the VBSEO one in the forum root :(

    Sorry for the confussion.

    Any ideas how I get them both working?

    Thanks

    VinylJunky

  4. #4
    Senior Member
    Real Name
    Keith Cohen
    Join Date
    Jul 2005
    Location
    Raleigh, NC USA
    Posts
    6,147
    Liked
    13 times
    In your case, you would have this in the .htaccess in your forum root:

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

    That should not affect anything in your site root, however.

  5. #5
    Member
    Real Name
    Fred
    Join Date
    Jun 2007
    Location
    UK
    Posts
    51
    Liked
    0 times
    Seems to work fine

    Thanks


    VinylJunky

  6. #6
    Member
    Real Name
    Fred
    Join Date
    Jun 2007
    Location
    UK
    Posts
    51
    Liked
    0 times

    Question

    I have found a small problem


    .mysitez.com gets refered to www.mysitez.com

    .mysitez.com/forum/ gets refered to www.mysitez.com/forum

    .mysitez.com/forum doesnt refer to www.mysitez.com/forum it stays at .mysitez.com/forum and shows Page Cannot Be Found 404

    How weird

    Anybody any ideas?

    Thanks

    VinylJunky

  7. #7
    Senior Member Thomas Hoehl's Avatar
    Real Name
    Thomas
    Join Date
    Jul 2005
    Location
    Ockershausen, Germany
    Posts
    1,329
    Liked
    3 times
    Try this (in Root folder, not forum folder)

    Code:
    RewriteCond %{HTTP_HOST} !^www\.mysitez\.com$ [NC]
    RewriteRule ^(.*)$ http://www.mysitez.com$1 [R=301,L]
    Thomas Höhl / Crawlability Inc.
    vBSEO 3.3.2 freigegeben: vBSEO 3.3.2 veröffentlicht - Sicherheitsupdate

    vBSEO Styles: Version 1.0 PRO Für Alle Version 2.0 Für vBSEO Kunden


    Meine Seiten: www.vb-seo.de, www.ligafans.de und www.skats.de

  8. #8
    Member
    Real Name
    Fred
    Join Date
    Jun 2007
    Location
    UK
    Posts
    51
    Liked
    0 times
    Quote Originally Posted by Thomas Hoehl View Post
    Try this (in Root folder, not forum folder)

    Code:
    RewriteCond %{HTTP_HOST} !^www\.mysitez\.com$ [NC]
    RewriteRule ^(.*)$ http://www.mysitez.com$1 [R=301,L]
    I've given it a go but I still get the same result

    Im puzzled :(

    VinylJunky

  9. #9
    Senior Member Thomas Hoehl's Avatar
    Real Name
    Thomas
    Join Date
    Jul 2005
    Location
    Ockershausen, Germany
    Posts
    1,329
    Liked
    3 times
    Have you dissable it in the .htaccess File in "Forum root" (forum Folder) at the same time?

    T
    Thomas Höhl / Crawlability Inc.
    vBSEO 3.3.2 freigegeben: vBSEO 3.3.2 veröffentlicht - Sicherheitsupdate

    vBSEO Styles: Version 1.0 PRO Für Alle Version 2.0 Für vBSEO Kunden


    Meine Seiten: www.vb-seo.de, www.ligafans.de und www.skats.de

  10. #10
    Senior Member
    Real Name
    Keith Cohen
    Join Date
    Jul 2005
    Location
    Raleigh, NC USA
    Posts
    6,147
    Liked
    13 times
    Quote Originally Posted by VinylJunky View Post
    I have found a small problem


    .mysitez.com gets refered to www.mysitez.com

    .mysitez.com/forum/ gets refered to www.mysitez.com/forum

    .mysitez.com/forum doesnt refer to www.mysitez.com/forum it stays at .mysitez.com/forum and shows Page Cannot Be Found 404

    How weird

    Anybody any ideas?

    Thanks

    VinylJunky
    Try this: Add www to forum url with no trailing slash

  11. #11
    Member
    Real Name
    Fred
    Join Date
    Jun 2007
    Location
    UK
    Posts
    51
    Liked
    0 times
    I still get this behaviour

    .mysitez.com gets refered to www.mysitez.com

    .mysitez.com/forum/ gets refered to www.mysitez.com/forum

    .mysitez.com/forum doesnt refer to www.mysitez.com/forum

    I'd like .mysitez.com/forum to go to www.mysitez.com/forum

    These are my .htaccess files


    siteroot/.htaccess
    Code:
    #  mod_rewrite in use
    # Options +FollowSymlinks
    RewriteEngine On
    #  Uncomment following line if your webserver's URL
    #  is not directly related to physical file paths.
    # RewriteBase /
    # Rule for duplicate content removal : domain.com - Get online with a domain name and web hosting vs domain.com
     
    RewriteCond %{HTTP_HOST} !^www.mysitez.com$ [NC]
    RewriteRule ^(.*)$ http://www.mysitez.com$1 [R=301,L]
     
    # Rule to redirect sitemaps
    RewriteRule ^((urllist|sitemap).*.(xml|txt)(.gz)?)$ forum/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
     
    # ErrorDocument 404 http://www.mysitez.com/error404.htm

    /forum .htaccess
    Code:
     
    RewriteEngine On
    # Some servers require the Rewritebase directive to be
    # enabled (remove '#' at the beginning to activate)
    # Please note: when enabled, you must include the path
    # to your root vB folder (i.e. RewriteBase /forums/)
    # RewriteBase /forum/
    # Already stated in site root
    # RewriteCond %{HTTP_HOST} !^www.mysitez.com
    # RewriteRule (.*) http://www.mysitez.com/forum/$1 [L,R=301]
     
    RewriteRule ^((urllist|sitemap_).*.(xml|txt)(.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    RewriteCond %{QUERY_STRING} !vbseourl=
    RewriteCond %{REQUEST_URI} !(admincp/|modcp/|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} !^(admincp|modcp|clientscript|cpstyles|images)/
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1 [L,QSA]
    Its driving me nuts

    Thanks

    VinylJunky

  12. #12
    Senior Member
    Real Name
    Keith Cohen
    Join Date
    Jul 2005
    Location
    Raleigh, NC USA
    Posts
    6,147
    Liked
    13 times
    It looks like you didn't do what is suggested here: Add www to forum url with no trailing slash

    That needs to be done in your Forum .htaccess, and you will need to uncomment those lines.

  13. #13
    Member
    Real Name
    Fred
    Join Date
    Jun 2007
    Location
    UK
    Posts
    51
    Liked
    0 times
    Quote Originally Posted by Keith Cohen View Post
    It looks like you didn't do what is suggested here: Add www to forum url with no trailing slash

    That needs to be done in your Forum .htaccess, and you will need to uncomment those lines.
    Guys,

    It works now, I owe you a beer

    I added this line to forum/.htaccess
    RewriteCond %{REQUEST_URI} forum/

    Thank you, I can now stop banging my head on the keyboard.

    The help I get in this forum is exceptional

    VinylJunky

  14. #14
    Senior Member Thomas Hoehl's Avatar
    Real Name
    Thomas
    Join Date
    Jul 2005
    Location
    Ockershausen, Germany
    Posts
    1,329
    Liked
    3 times
    You welcome.
    Thomas Höhl / Crawlability Inc.
    vBSEO 3.3.2 freigegeben: vBSEO 3.3.2 veröffentlicht - Sicherheitsupdate

    vBSEO Styles: Version 1.0 PRO Für Alle Version 2.0 Für vBSEO Kunden


    Meine Seiten: www.vb-seo.de, www.ligafans.de und www.skats.de

Posting Permissions

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