2

I have a working Joomla 3.2 website and would like to direct all non www traffic to my www address.

I have tried to add the code below to my .htaccess file, which I presumed was working however it seems not. I implemented this code yesterday, the changes were not immediate - I checked this morning and my site was unavailable. As soon as I removed the code all was well again.

Am I doing something wrong? What would cause this issue?

# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

All help appreciated.

1
  • You are missing the $ at the end of the condition line.
    – BodgeIT
    Jul 19, 2014 at 8:37

3 Answers 3

3

I suggest using universal code, no need to retype domain everytime you want to apply the same thing on other domains.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
0
1

I believe the issue is in your Rewrite Condition.

Try using this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L] 
0

This is the one I use

The rewrite engine should already be on in the .htaccess file of joomla so dont repeat that line. Make sure the force www section is directly after the Rewrite On statement.

# Only do this line ONCE!
RewriteEngine On

# Force the "www."
RewriteCond %{HTTP_HOST} !^www\.domain\.biz$ [NC]
RewriteRule ^(.*)$ http://www.domain.biz/$1 [R=301,L]

I am using this on 3 Joomla 3.x sites at the moment with no issues

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.