Redirect non www to www
-
- Joomla! Apprentice
- Posts: 25
- Joined: Mon Jan 23, 2012 11:18 am
Redirect non www to www
I want to redirect all my URL's with non www to URL's with www. I put redirect 301 code into .htaccess of my domain but all i get is to redirect only my main page. (ex. mysite.com redirect to www.mysite.com) . When i enter other URL's nothing happen. (ex. mysite.com/services/ is not redirecting to www.mysite.com/services/) .What can i do to redirect every single page of my site with www in front? Is there any plugin extension for that problem?
- toivo
- Joomla! Master
- Posts: 13095
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Zagreb, Croatia
Re: Redirect non www to www
Try this:The $1 entry copies the rest of the request to the rewritten URL.
Code: Select all
#### redirect example.com to http://www.example.com ####
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Toivo Talikka, Global Moderator
-
- Joomla! Apprentice
- Posts: 25
- Joined: Mon Jan 23, 2012 11:18 am
Re: Redirect non www to www
I put that code in .htaccess and the same thing happen...
My site is indexed with www.example.com and with example.com. When someone enters to my main page example.com everything is ok because it redirect him to www.example.com. But if someone enters for ex. example.com/services/ from google then all the browsing in my site is without www. That is because the redirect 301 is only for the main page (example.com)???
I enter sites without that problem and when i change the url from www.example.com/something/ to example.com/something/ and hit enter, it redirects to www.example.com/something/. How they do that??
My site is indexed with www.example.com and with example.com. When someone enters to my main page example.com everything is ok because it redirect him to www.example.com. But if someone enters for ex. example.com/services/ from google then all the browsing in my site is without www. That is because the redirect 301 is only for the main page (example.com)???
I enter sites without that problem and when i change the url from www.example.com/something/ to example.com/something/ and hit enter, it redirects to www.example.com/something/. How they do that??
- toivo
- Joomla! Master
- Posts: 13095
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Zagreb, Croatia
Re: Redirect non www to www
The code I listed works for me and others, too: http://www.thesitewizard.com/apache/red ... main.shtml
Toivo Talikka, Global Moderator
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Jan 16, 2012 2:18 pm
- Location: Lancaster
- Contact:
Re: Redirect non www to www
perhaps there is another htaccess file in a subdirectory?
web design - secondsighting.co.uk
-
- Joomla! Apprentice
- Posts: 25
- Joined: Mon Jan 23, 2012 11:18 am
Re: Redirect non www to www
Ok, the problem solved. I was putting the code after joomla codes in .htaccess file. I put the code in the right place and everything is ok. Thanks.
- brunoalec
- Joomla! Apprentice
- Posts: 31
- Joined: Tue Sep 02, 2008 5:49 pm
- Location: Rio - Brasil
- Contact:
Re: Redirect non www to www
Hi Haralake, can you share the code you used to solve your problem please ?
with best regards
Bruno Alecrim
with best regards
Bruno Alecrim
-
- Joomla! Apprentice
- Posts: 25
- Joined: Mon Jan 23, 2012 11:18 am
Re: Redirect non www to www
You must put this code before joomla codes in .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite\.com [NC]
RewriteRule ^(.*)$ http://www.yoursite\.com/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite\.com [NC]
RewriteRule ^(.*)$ http://www.yoursite\.com/$1 [L,R=301]
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: Redirect non www to www
The above code does not redirect all non-canonical URLs.
Try this:
See also: http://forum.joomla.org/viewtopic.php?t=598832
Try this:
Code: Select all
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Online since 1995.
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: Redirect non www to www
Unfortunately the code linked to by toivo has limited use.
For a site at www.example.com the code redirects requests for example.com but fails to redirect requests for www.example.com:80 [port], example.com:80 [port], www.example.com. [period], example.com. [period], www.example.com.:80 [period and port], and example.com.:80 [period and port], all of which are valid alternative hostnames and all of which pose the same duplicate content problem.
For a site at www.example.com the code redirects requests for example.com but fails to redirect requests for www.example.com:80 [port], example.com:80 [port], www.example.com. [period], example.com. [period], www.example.com.:80 [period and port], and example.com.:80 [period and port], all of which are valid alternative hostnames and all of which pose the same duplicate content problem.
Online since 1995.
- brunoalec
- Joomla! Apprentice
- Posts: 31
- Joined: Tue Sep 02, 2008 5:49 pm
- Location: Rio - Brasil
- Contact:
Re: Redirect non www to www
Newbie question:
1 - Where should I insert the code ? In the beginning, botton or anywhere inside the .htaccess file?
2 - Doing that I dont need to worry about this issue, or should I do something more, like using any plugin ?
PS: Sorry about my bad english writing.
With best regards
1 - Where should I insert the code ? In the beginning, botton or anywhere inside the .htaccess file?
2 - Doing that I dont need to worry about this issue, or should I do something more, like using any plugin ?
PS: Sorry about my bad english writing.
With best regards
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: Redirect non www to www
Make sure you have the latest version of the htaccess file. If you're using an old version of Joomla make sure you get a new htaccess file from the latest Joomla installer.
There's a section in the new htaccess file that explains where any redirect should go. In general it goes after all code that blocks malicious requests and it must go before any code which internally rewrites any request.
There's a section in the new htaccess file that explains where any redirect should go. In general it goes after all code that blocks malicious requests and it must go before any code which internally rewrites any request.
Online since 1995.
-
- Joomla! Apprentice
- Posts: 6
- Joined: Tue Feb 14, 2012 4:44 am
Re: Redirect non www to www
Using a 301 redirect on the “non-www” version of the URL, which is essentially a “permanent” redirect in server talk, you can effectively consolidate all of your link popularity to a single URL. This consolidation will serve to increase your website’s chances of obtaining and maintaining top rankings.
Read more: How to 301 Redirect Non-WWW to WWW URLs | StepForth Web Marketing Inc.
Under Creative Commons License: Attribution
Read more: How to 301 Redirect Non-WWW to WWW URLs | StepForth Web Marketing Inc.
Under Creative Commons License: Attribution
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: Redirect non www to www
... or use the code in the post just a little bit back up this page.
Online since 1995.
-
- Joomla! Apprentice
- Posts: 30
- Joined: Mon Oct 11, 2010 5:57 am
Re: Redirect non www to www
I am trying a new free host and they don't seem to give access to .htaccess so I would like to know, as per the original question, if anyone knows of an extension that does this?
-
- Joomla! Fledgling
- Posts: 1
- Joined: Thu Nov 15, 2012 7:57 am
Re: Redirect non www to www
What .htaccess file are you altering? Make sure you alter the .htaccess file in the root of your old website. This article might be helpfull for you: http://www.kmbytes.com/blog/redirect-to ... -redirect/
- Obir
- Joomla! Apprentice
- Posts: 45
- Joined: Wed Jun 03, 2009 4:10 pm
- Location: Honolulu, HI
- Contact:
Re: Redirect non www to www
Thanks for this post. I was placing the code in the wrong .htaccess file and in the wrong place within the file. I placed this into the root .htaccess before the joomla code and it worked perfectly. Thanks again.
-
- Joomla! Fledgling
- Posts: 4
- Joined: Thu Nov 15, 2012 8:50 pm
- Location: Houston
- Contact:
Re: Redirect non www to www
Thanks for this info, I will try this with my .htaccess file.
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: Redirect non www to www
The non-www to www redirect does NOT "go before the Joomla code".
It goes somewhere in the middle of the Joomla code, specifically in the place where it mentions to "insert redirects here".
Make sure you have the latest version of the htaccess file. Even if you are continuing to use an old version of Joomla, make sure you get the latest version of the Joomla htaccess file from the latest Joomla installer.
This file explains exactly where the redirects should go.
It goes somewhere in the middle of the Joomla code, specifically in the place where it mentions to "insert redirects here".
Make sure you have the latest version of the htaccess file. Even if you are continuing to use an old version of Joomla, make sure you get the latest version of the Joomla htaccess file from the latest Joomla installer.
This file explains exactly where the redirects should go.
Online since 1995.
- changlee
- Joomla! Explorer
- Posts: 426
- Joined: Tue Nov 20, 2007 11:05 am
- Location: Greece
- Contact:
Re: Redirect non www to www
I added this code to the last part of my .htaccesstoivo wrote:Try this:The $1 entry copies the rest of the request to the rewritten URL.Code: Select all
#### redirect example.com to http://www.example.com #### RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
It works perfect but I face one small bug:
For example, if you click the url http://www.blb.gr/seo-websites it works perfect, but if you remove the www. and click it (http://blb.gr/seo-websites), it redirects to http://www.blb.gr/index.php
What else have we to do?
If you do not programm your life, someone else will do it for you.
SMTP Newsletter APP: https://www.emailbat.com
SMTP Newsletter APP: https://www.emailbat.com
-
- Joomla! Fledgling
- Posts: 1
- Joined: Fri Dec 06, 2013 5:43 pm
Re: Redirect non www to www
remove $ from: ^example\.com$changlee wrote:toivo wrote: It works perfect but I face one small bug:
For example, if you click the url http://www.blb.gr/seo-websites it works perfect, but if you remove the www. and click it (http://blb.gr/seo-websites), it redirects to http://www.blb.gr/index.php
What else have we to do?
Try this way:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
- changlee
- Joomla! Explorer
- Posts: 426
- Joined: Tue Nov 20, 2007 11:05 am
- Location: Greece
- Contact:
Re: Redirect non www to www
That was great.
What have I to do in order to redirect more than one parked domain for the same website?
To copy the same code for each domain?
Eg
Thanks again
What have I to do in order to redirect more than one parked domain for the same website?
To copy the same code for each domain?
Eg
Code: Select all
#### redirect example.com to http://www.example.com ####
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Code: Select all
#### redirect otherdomain.com to http://www.otherdomain.com ####
RewriteCond %{HTTP_HOST} ^otherdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.otherdomain.com/$1 [R=301,L]
If you do not programm your life, someone else will do it for you.
SMTP Newsletter APP: https://www.emailbat.com
SMTP Newsletter APP: https://www.emailbat.com
-
- Joomla! Apprentice
- Posts: 13
- Joined: Thu Jan 29, 2015 12:02 pm
- Location: Piraeus, Greece
- Contact:
Re: Redirect non www to www
I am also using three domains for my website
What exactly have I to set in .htaccess ?

What exactly have I to set in .htaccess ?
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Mar 13, 2015 8:06 am
- Location: South Africa
- Contact:
Re: Redirect non www to www
what is the seo value of redirecting www version of the site to non www version of the site for the rest of the pages except the home page. i figured that if u go to google webmaster tools and in site settings u tell google which version of ur site u want then thats all u need to do
- changlee
- Joomla! Explorer
- Posts: 426
- Joined: Tue Nov 20, 2007 11:05 am
- Location: Greece
- Contact:
Re: Redirect non www to www
I use two domains for my website and I need the .httacces to redirect ONLY to www.domain1.com and www.domain2.com
Not to domain1.com and domain2.com
Not to domain1.com and domain2.com
If you do not programm your life, someone else will do it for you.
SMTP Newsletter APP: https://www.emailbat.com
SMTP Newsletter APP: https://www.emailbat.com
-
- Joomla! Apprentice
- Posts: 13
- Joined: Thu Jan 29, 2015 12:02 pm
- Location: Piraeus, Greece
- Contact:
Re: Redirect non www to www
Anyone about that fix?
- changlee
- Joomla! Explorer
- Posts: 426
- Joined: Tue Nov 20, 2007 11:05 am
- Location: Greece
- Contact:
Re: Redirect non www to www
Is anyone here that has used that NON www. for more than two domains in same website?


If you do not programm your life, someone else will do it for you.
SMTP Newsletter APP: https://www.emailbat.com
SMTP Newsletter APP: https://www.emailbat.com
-
- Joomla! Fledgling
- Posts: 1
- Joined: Sun May 10, 2015 1:45 pm
- Contact:
Re: Redirect non www to www
Thanks for this info, I will try this with my .htaccess file.
-----------------------------
http://dirtv.jimdo.com/
-----------------------------
http://dirtv.jimdo.com/
- changlee
- Joomla! Explorer
- Posts: 426
- Joined: Tue Nov 20, 2007 11:05 am
- Location: Greece
- Contact:
Re: Redirect non www to www
Did you tried for two domains also?
If you do not programm your life, someone else will do it for you.
SMTP Newsletter APP: https://www.emailbat.com
SMTP Newsletter APP: https://www.emailbat.com