Aug
www or no www in urls
Filed Under (Facebook, Joomla! 1.0, Joomla! 1.5, Ubuntu) by khawaib on 01-08-2010
Tagged Under : Facebook, google, htaccess, Joomla! 1.5, mod rewrite, no www, search engines, website, www
You can enter your website urls with a www or with no www. Which is better I leave for you to google and find out yourself. Using both is not a good idea as search engines and Facebook will not treat them same and will cause problems.
Solution is to force one of them to be used and not both. So if a users enters http://www.youtsite.com gets to http://yoursite.com and vice versa.
Solutions 1: Using Mod Rewrite
Following code should be placed in htaccess file in root directory of your website.
If your want to http://www.yoursite.com use following code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>
If your want to http://yoursite.com use following code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
</IfModule>
Joomla website users:
You can use following free plugin from JED
http://extensions.joomla.org/extensions/site-management/url-redirection/10527


