The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Fri Jan 18, 2013 11:41 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Sep 21, 2010 2:39 pm
Posts: 152
I want to redirect the www. version of the site to the non-www version

Right now I am kind of confused, because I have found SEVERAL different suggested codes to do this and I cannot evaluate which one is the best one.
I would also value the code that is valid not just for Joomla (if it can be more specific to this platform, I don't know) but other CMSs as well, like Wordpress

So, I have found the following codes.

1) This is the one provided in the Master htaccess file for Joomla
Code:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]


2) Or
Code:
RewriteCond %{HTTP_HOST} ^www.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L] 


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


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


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


Which one is the most highly recommended?


Top
 Profile  
 
PostPosted: Sat Jan 19, 2013 6:52 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon May 14, 2012 9:56 am
Posts: 159
Location: Irving, TX 75039
I suggest this one.

RewriteBase /
RewriteCond % ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

_________________
http://www.usjoomlaforce.com/joomla-mig ... rvice.html -- Joomla Migration Service
http://www.usjoomlaforce.com/joomla-hacking-fix.html -- Professional Hack Recovery Service


Top
 Profile  
 
PostPosted: Sat Jan 19, 2013 7:51 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Sep 21, 2010 2:39 pm
Posts: 152
Thank you for your reply @Yesceeohhh
Why would you recommend this particular one? Does it do something that others don't, you have been using it effectively etc?

Thanks...trying to understand a little bit myself


Top
 Profile  
 
PostPosted: Mon Jan 21, 2013 2:46 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Fri Nov 13, 2009 1:33 pm
Posts: 500
From what I can see all others you've mentioned should work just fine. The one recommended by Yesceeohhh seems like the one that is most clear if you ever end up checking your .htaccess file again and start wondering: "what did that setting do?"

_________________
http://www.themepartner.com/ - Easy to Use Professional Joomla Templates
http://www.themepartner.com/download-free-ebook/ - Download FREE Joomla! 3 SEO ebook


Top
 Profile  
 
PostPosted: Mon Jan 21, 2013 5:02 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sat Oct 15, 2011 4:05 pm
Posts: 198
Hello,

In addition to this modification made in the .htaccess file, (for seo purpose) do not forget to make an update in google analytics in goal to merge the rank/traffic of http://www.example.com and http://example.com ( Process explained here.


Top
 Profile  
 
PostPosted: Wed Jan 23, 2013 8:26 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Sep 21, 2010 2:39 pm
Posts: 152
Thank you all for your answers...

I am principally looking about the most all-around effective rewrite code...
Several may be working, but there may be differences - pertaining to possible url configurations or cases - which may make one better than the other, more "complete" ( ? ). I don't know...

I am just supposing that if there was just a single straightforward way to do it, there wouldn't be so many different rewrite codes around for pointing www. to non-www.

I am looking for the "all-around" best, if there is such a thing...


Yes, setting the preference in google is important. I have set the preference there, I just want to make sure the redirection is doing its part as well


Top
 Profile  
 
PostPosted: Sat Jan 26, 2013 3:25 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 06, 2011 8:52 am
Posts: 18
Location: Bucharest / Romania
Hope you will not forget to redirect also your index page :
http://www.example.com/index.php => Redirect 301 to http://example.com .

If your website it's made in static HTML, than you need to redirect your index.html page.

In this way you will avoid duplicate content issues, and you will have a more powerful first page!

_________________
optimizare site http://www.webdesignoptimizare.ro/optimizare-seo.html si articole din zona de marketing web http://www.webdesignoptimizare.ro si promovare online


Top
 Profile  
 
PostPosted: Sat Jan 26, 2013 7:18 pm 
Joomla! Hero
Joomla! Hero

Joined: Sat Feb 09, 2008 8:27 am
Posts: 2264
Location: California, USA
PierreB wrote:
I am principally looking about the most all-around effective rewrite code...
Several may be working, but there may be differences - pertaining to possible url configurations or cases - which may make one better than the other, more "complete" ( ? ). I don't know...

I am looking for the "all-around" best, if there is such a thing...

Me personally when I am looking for .htaccess redirect codes or information about them I look at posts made by a user called g1smd as he seems very knowledgeable about it. The following threads contain some code he provided to redirect non-www to www.

viewtopic.php?p=2513449#p2513459
viewtopic.php?p=1719982#p2491980

Make sure to read the entire threads for more information on what the code does.

Another good thread to read (though it is to force non-www to www) is:

viewtopic.php?t=598832

A lot more information to read can be found by this user. Just type in a Google search the following:

site:forum.joomla.org redirect www to non-www g1smd

Or alternatively do a search for "redirect www to non-www g1smd" which will provide information on various forums.

Personally I use the code provided in one of the above links (viewtopic.php?p=2513449#p2513459) to force all non-www to www helping with Canonical URL issues.

The following is also a good video to watch on Canonicalization:

http://www.[youtube].com/watch?v=Cm9onOGTgeM

Mark


Top
 Profile  
 
PostPosted: Sun Jan 27, 2013 3:29 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Oct 18, 2012 2:30 pm
Posts: 13
Location: Paris
PierreB wrote:
Thank you for your reply @Yesceeohhh
Why would you recommend this particular one? Does it do something that others don't, you have been using it effectively etc?

Thanks...trying to understand a little bit myself


Hi Pierre I have done the same thing for my website . I redirect www to non www , and nothing changed . I afraid that something goes wrong ,but everything is ok .


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 



Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group