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: Select all
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Code: Select all
RewriteCond %{HTTP_HOST} ^www.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]
Code: Select all
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Code: Select all
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com [NC]
RewriteRule ^(.*)$ http://%1.example.com/$1 [R=301,L]
Code: Select all
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]