Page 5 of 18 FirstFirst 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 LastLast
Results 61 to 75 of 267
Like Tree3Likes

[How to] Setup www.yourdomain.com or yourdomain.com (www vs. non-www) - With .htaccess 301 redirects

This is a discussion on [How to] Setup www.yourdomain.com or yourdomain.com (www vs. non-www) - With .htaccess 301 redirects within the General Discussion forums, part of the vBSEO SEO Plugin category; So is it better to use www in .htaccess file or not www?...

  1. #61
    Junior Member
    Real Name
    Ibrar Sajid
    Join Date
    Nov 2008
    Posts
    18
    Liked
    0 times
    So is it better to use www in .htaccess file or not www?

  2. #62
    Senior Member
    Real Name
    Joseph Ward
    Join Date
    Jun 2005
    Posts
    23,847
    Liked
    33 times
    Blog Entries
    9
    With Google's Webmaster tools allowing you to select your preference, it is not as much of a debate any more.

    Check out:
    Canonicalization & SEO : Should I use WWW or not?

    I prefer to NOT use www. Less to type, and it is more reflective of the reality that it is not needed. That is... if you are using a web browser in 2008, then we know that it's the "World Wide Web" (www). It's also easier to squeeze into business cards, banners, and other graphics, etc.

    However, use of www was the traditional way to indicate the HTTP protocol for the Web. Many users (of all levels of tech skills) have that firmly locked into their brains. As a result, they may commonly link to your site with a link that includes the www whether you do or not.

    I would say. Whatever you choose, put a htaccess redirect in place, and ALWAYS use your Google Webmaster Tools to indicate your preference.

  3. #63
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times
    What will be the nginx version of the rewrite, if I choose NON-WWW.

  4. #64
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    You can use this:

    Code:
    if ($host = 'www.domain.com' ) {
    rewrite ^/(.*)$ http://domain.com/$1 permanent;
    }
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  5. #65
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times
    thanks, its working good.

    btw, can I put it anywhere between server { .... }

    I currently have it like this, and works fine.

    Code:
    server {
        listen          80;
        server_name     domain.com;
        access_log      /home/username/logs/access.log main;
        error_log       /home/username/logs/error.log debug;
    
        if ($host = 'www.domain.com' ) {
        rewrite ^/(.*)$ http://domain.com/$1 permanent;
       }
    .
    .
    .
    }
    1. Does this look good?




    2. Another small nginx question i was wondering about:-

    I have seen few nginx.conf's that have two blocks of server code, something like this:-

    Code:
    server {
            listen   80;
            server_name  example.com;
            rewrite ^/(.*) http://www.example.com/$1 permanent;
    }
    
    server {
            listen   80;
            server_name www.example.com;
    
            access_log /home/username//logs/access.log;
            error_log /home/username/logs/error.log;
    ........
    .....
    }
    What does it mean? When I try to do something like that, it gives me redirection loop error.

    Thanks

  6. #66
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    1. Yes, it should work directly in server{} section.

    2. You can use that if you want to handle www and non-ww *differently*. Otherwise you can use one block:
    Code:
    server {
            listen   80;
            server_name  example.com www.example.com;
            rewrite ^/(.*) http://www.example.com/$1 permanent;
    }
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  7. #67
    Senior Member
    Real Name
    Chris
    Join Date
    Aug 2005
    Location
    North Carolina
    Posts
    358
    Liked
    9 times
    So when I type in
    http://gunandgame.com/forums
    http://gunandgame.com/forums/

    I get a 404

    Is it just me or am I not doing a redirect correctly? I thought it was pretty straight forward?

  8. #68
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    The redirect seems to work for me on your site.
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  9. #69
    Member
    Real Name
    Hiiragi
    Join Date
    Jun 2008
    Posts
    52
    Liked
    0 times
    I have had my site with www for a couple months now after changing my domain and server but I want to swap to non-www due to the longer nature of my domain name. I tried this twice before but I stumbled on cookie problems where I couldn't login or logout correctly with a 301 redirect via .htaccess from www to non-www.

    Was it actually the redirect that gave me the cookie problem and if so, is there a way to prevent it?

  10. #70
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times
    As described in the first post, why is ! removed from NON-WWW version:-

    Choosing WWW:-

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

    Choosing NON-WWW:-

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

  11. #71
    Senior Member webwizzy's Avatar
    Real Name
    Vinayak
    Join Date
    Aug 2008
    Location
    India
    Posts
    257
    Liked
    0 times
    okay adding a ! in non-www gives a redirection loop error.

    How do I take care of parked domains to redirect to main domain? My main domain is non-www.

    thanks

  12. #72
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    "!" means "not equal".

    You can use this:
    Code:
    RewriteCond %{HTTP_HOST} !^example\.com$
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  13. #73
    Junior Member
    Real Name
    Forumguy
    Join Date
    Mar 2009
    Posts
    17
    Liked
    0 times
    Go to Dashboard > Tools > Set preferred domain

    it is now:

    Go to Dashboard > Settings > Set preferred domain

  14. #74
    Junior Member
    Real Name
    Forumguy
    Join Date
    Mar 2009
    Posts
    17
    Liked
    0 times
    Using vbseo 3.3 Gold

    It was previously recommended to delete the .htaccess file within a forum child directory

    There's lines in that forum .htaccess file which haven't been addressed though.

    Code which is in the forum file:

    Code:
    RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    
    RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap)
    RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !^(admincp|modcp|clientscript|cpstyles|images)/
    RewriteRule ^(.+)$ vbseo.php [L,QSA]
    If these lines provide benefit, then the best recommendation will be to just modify the .htaccess file in the forum folder with the necessary code.
    Last edited by shanghaiexpatman; 04-05-2009 at 03:46 AM.

  15. #75
    Member
    Real Name
    Nathan
    Join Date
    Mar 2009
    Posts
    73
    Liked
    0 times
    what does the L do in [L, r=301]

Page 5 of 18 FirstFirst 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 LastLast

Similar Threads

  1. Urgent help with htaccess and 301 redirects
    By markbolyard in forum URL Rewrite Settings
    Replies: 4
    Last Post: 12-02-2007, 05:24 PM
  2. htaccess redirects when moving folder
    By I, Brian in forum Troubleshooting
    Replies: 3
    Last Post: 10-05-2007, 02:47 PM
  3. Help with initial htaccess setup
    By mhc1576 in forum URL Rewrite Settings
    Replies: 1
    Last Post: 12-28-2006, 07:44 AM
  4. Replies: 6
    Last Post: 10-23-2005, 01:32 PM

Posting Permissions

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