So is it better to use www in .htaccess file or not www?
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?...
So is it better to use www in .htaccess file or not www?
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.
What will be the nginx version of the rewrite, if I choose NON-WWW.
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!
thanks, its working good.
btw, can I put it anywhere between server { .... }
I currently have it like this, and works fine.
1. Does this look good?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; } . . . }
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:-
What does it mean? When I try to do something like that, it gives me redirection loop error.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; ........ ..... }
Thanks
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!
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?
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!
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?
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:-
ThanksCode:RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
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
"!" 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!
Go to Dashboard > Tools > Set preferred domain
it is now:
Go to Dashboard > Settings > Set preferred domain
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:
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.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]
Last edited by shanghaiexpatman; 04-05-2009 at 03:46 AM.
what does the L do in [L, r=301]