Redirect domain.com to www.domain.com in Gallery 3

daholzer

Joined: 2013-05-17
Posts: 18
Posted: Thu, 2013-05-30 21:52

Hi I'm trying to do a redirect in .htaccess to redirect non wwww url request to the www version.

I tried using this code:

RewriteEngine on 

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

but what I get is domain.com redirecting to http://www.domian.com/index.php?kohana_uri=

I should note that I have uncommented the section in .htacces that removes index.php.

 
MikeLFD

Joined: 2013-03-22
Posts: 79
Posted: Fri, 2013-05-31 01:32
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
 
daholzer

Joined: 2013-05-17
Posts: 18
Posted: Fri, 2013-05-31 01:48
MikeLFD wrote:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Unfortunately Mike, that code gives me the exact same results as my code

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2013-05-31 04:08

Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo.
I'm no rewrite expert Vodouisant :-) , so try:

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

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
daholzer

Joined: 2013-05-17
Posts: 18
Posted: Sat, 2013-06-01 00:10
floridave wrote:
Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo.
I'm no rewrite expert Vodouisant :-) , so try:

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

Dave

This didn't work either. It didn't seem to do any redirect at all.

 
daholzer

Joined: 2013-05-17
Posts: 18
Posted: Sat, 2013-06-01 00:09

OK I figured it out if anyone is interested. The code that worked for me was

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

You were pretty close Dave, just needed the [NC].

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2013-06-01 01:48

I missed that spell pocient ingredient. Now your the voodoo expert! :-)

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team