Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Redirect www to non-www
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
creat1v1ty  
View profile  
 More options Apr 12 2012, 1:03 am
From: creat1v1ty <justin.r.ran...@gmail.com>
Date: Wed, 11 Apr 2012 22:03:39 -0700 (PDT)
Local: Thurs, Apr 12 2012 1:03 am
Subject: Redirect www to non-www

Quick question - I know this should be very easy to figure out myself, but
I keep finding conflicting information when I try to find the solution, and
I'm a stickler for doing/learning things the right way.

I want to redirect all www traffic to non-www.

I am using a fresh copy of Cake 2.1.1 - no changes have been made to any of
the .htaccess files.

*/site/.htaccess*
==========================
<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

*/site/app/.htaccess*
==========================
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

Which .htaccess file should the rewrite conditions/rules be placed in? What
are the proper rewrite conditions/rules to use?

Thanks in advance.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kdubya  
View profile  
 More options Apr 13 2012, 9:43 am
From: kdubya <kenwin...@winanstech.com>
Date: Fri, 13 Apr 2012 06:43:20 -0700 (PDT)
Local: Fri, Apr 13 2012 9:43 am
Subject: Re: Redirect www to non-www

I have always made rewrite rule changes in the /site/.htacess file
exclusively.

I don't really know why the  /site/app/.htaccess (or for that matter
/site/app/webroot/.htaccess) files exist. I can't even dream up a scenario
where those files would ever be applied - as long as the /site/.htaccess
file exists.

Ken


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kdubya  
View profile  
 More options Apr 13 2012, 9:51 am
From: kdubya <kenwin...@winanstech.com>
Date: Fri, 13 Apr 2012 06:51:52 -0700 (PDT)
Local: Fri, Apr 13 2012 9:51 am
Subject: Re: Redirect www to non-www

I realized I answered only part of your question. I have done the opposite
of what you are asking - redirecting domain.tld -> www.domain.tld (making
the www.domain.tld the canonical URL).

The /site/.htaccess file I use contains:
<IfModule mod_rewrite.c>
   RewriteEngine on

   RewriteCond %{HTTP_HOST} ^domain.com$
   RewriteRule ^/?$ "http\:\/\/www.domain.com" [R=301,L]

   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

HTH,
Ken


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lowpass  
View profile  
 More options Apr 13 2012, 6:29 pm
From: lowpass <zijn.digi...@gmail.com>
Date: Fri, 13 Apr 2012 18:29:09 -0400
Local: Fri, Apr 13 2012 6:29 pm
Subject: Re: Redirect www to non-www

On Fri, Apr 13, 2012 at 9:43 AM, kdubya <kenwin...@winanstech.com> wrote:
> I have always made rewrite rule changes in the /site/.htacess file
> exclusively.

> I don't really know why the  /site/app/.htaccess (or for that matter
> /site/app/webroot/.htaccess) files exist. I can't even dream up a scenario
> where those files would ever be applied - as long as the /site/.htaccess
> file exists.

It depends on what the DocumentRoot is set to. Of course, if one has
the ability to set it to /path/to/site/app/webroot in the main config
then the rewrite rules can be placed there and all .htaccess files
removed for better performance.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Justin Edwards  
View profile  
 More options Apr 13 2012, 6:50 pm
From: Justin Edwards <justinledwa...@gmail.com>
Date: Fri, 13 Apr 2012 17:50:37 -0500
Local: Fri, Apr 13 2012 6:50 pm
Subject: Re: Redirect www to non-www

You may also create another vhost for a catchall for whatever things you
might want to redirect there, and give it a 301 to where you do want them
to go.   I do things like this to force https, or add the www


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Robert Marquez  
View profile  
 More options Apr 13 2012, 6:53 pm
From: Angel Robert Marquez <angel.marq...@gmail.com>
Date: Fri, 13 Apr 2012 15:53:01 -0700
Local: Fri, Apr 13 2012 6:53 pm
Subject: Re: Redirect www to non-www

it's nice to see developers share information without being total douche
bags.

On Fri, Apr 13, 2012 at 3:50 PM, Justin Edwards <justinledwa...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
euromark  
View profile  
 More options Apr 13 2012, 9:37 pm
From: euromark <dereurom...@googlemail.com>
Date: Fri, 13 Apr 2012 18:37:46 -0700 (PDT)
Local: Fri, Apr 13 2012 9:37 pm
Subject: Re: Redirect www to non-www

@kdubya: thats actually how you normally do it anyway
what kdubya wants is just not how it is done... (you always use www as the
actual site and 301 redirect from non-www there) imo

Am Freitag, 13. April 2012 15:51:52 UTC+2 schrieb kdubya:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lowpass  
View profile  
 More options Apr 13 2012, 9:50 pm
From: lowpass <zijn.digi...@gmail.com>
Date: Fri, 13 Apr 2012 21:50:43 -0400
Local: Fri, Apr 13 2012 9:50 pm
Subject: Re: Redirect www to non-www
I think you mean "what creat1v1ty wants" there. And I agree that it's
better to redirect to www for the default.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
creat1v1ty  
View profile  
 More options Apr 14 2012, 1:32 am
From: creat1v1ty <justin.r.ran...@gmail.com>
Date: Fri, 13 Apr 2012 22:32:16 -0700 (PDT)
Local: Sat, Apr 14 2012 1:32 am
Subject: Re: Redirect www to non-www

Ok, thanks for all the good feedback, guys. To confirm...

My website is hosted on a shared server, so my doc root is public_html, in
which I have a Cake installation.

public_html
     - app
          - webroot
               - .htaccess  *(3)*
          - .htaccess  *(2)*
     - libs
     - plugins
     - vendors
     - .htaccess  *(1)*
     - index.php

That being said, which .htaccess file should I place my redirect
conditions/rules in? 1, 2, or 3?

Also, as kdubya posted, here is the condition/rule I plan on using:

RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/?$ "http\:\/\/www.domain.com<http://www.google.com/url?sa=D&q=www.domain.com&usg=AFQjCNF2VZnNvBDuF...>"
[R=301,L]

Is this the best/correct usage?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
euromark  
View profile  
 More options Apr 14 2012, 7:05 am
From: euromark <dereurom...@googlemail.com>
Date: Sat, 14 Apr 2012 04:05:13 -0700 (PDT)
Local: Sat, Apr 14 2012 7:05 am
Subject: Re: Redirect www to non-www

ops - copy and paste can be a .. sometiems :)

might work.
but I usually use the more generic one:

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

mark

Am Samstag, 14. April 2012 07:32:16 UTC+2 schrieb creat1v1ty:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
creat1v1ty  
View profile  
 More options Apr 14 2012, 2:19 pm
From: creat1v1ty <justin.r.ran...@gmail.com>
Date: Sat, 14 Apr 2012 11:19:21 -0700 (PDT)
Local: Sat, Apr 14 2012 2:19 pm
Subject: Re: Redirect www to non-www

cool, thanks euromark. Will you please confirm which .htaccess file this
should go in, based on my doc root being public_html...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lowpass  
View profile  
 More options Apr 15 2012, 3:32 pm
From: lowpass <zijn.digi...@gmail.com>
Date: Sun, 15 Apr 2012 15:32:01 -0400
Local: Sun, Apr 15 2012 3:32 pm
Subject: Re: Redirect www to non-www

On Sat, Apr 14, 2012 at 2:19 PM, creat1v1ty <justin.r.ran...@gmail.com> wrote:
> cool, thanks euromark. Will you please confirm which .htaccess file this
> should go in, based on my doc root being public_html...

In #1 -- the one directly inside public_html.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »