Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion Adding (or removing) "www" without mod_rewrite
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
 
RSL  
View profile  
 More options Aug 7 2008, 8:19 am
From: RSL <sco...@gmail.com>
Date: Thu, 7 Aug 2008 08:19:54 -0400
Local: Thurs, Aug 7 2008 8:19 am
Subject: Re: Adding (or removing) "www" without mod_rewrite
Yes. You can indeed redirect based on if request.subdomains.first ==
"www". I've had to do so in the past when I couldn't change the Apache
confs. It will cost an extra Rails request though, so if you can solve
it by rewriting the configurations, that's probably preferable.

RSL

On Thu, Aug 7, 2008 at 7:35 AM, Andrew Stone <stoneli...@gmail.com> wrote:

> On Thu, Aug 7, 2008 at 6:02 AM, Peter Cooper <pcoo...@gmail.com> wrote:

>> On Aug 7, 7:39 am, Peter Cooper <pcoo...@gmail.com> wrote:
>> > How do other Passenger users deal with removing or adding "www" to
>> > their URLs without using mod_rewrite?

>> > For example, if I have a sitehttp://www.example.com/, I might want
>> > all visitors tohttp://example.com/to redirect tohttp://www.example.com/
>> > (or vice versa). This is recommended for SEO purposes to help prevent
>> > duplicate content being detected. Normally you'd use a rewrite rule
>> > with a host-based condition to deal with this, but is there a way of
>> > doing it without activating mod_rewrite?

>> > I could always activate mod_rewrite and deal with it the classic way,
>> > but since it's hinted that this isn't a Good Thing (tm) to do, I'd
>> > like to avoid doing that.

>> Just to add in case it's useful for someone else, a few people have
>> suggested on Twitter having two virtual hosts, one for www and one
>> without, and then using a simple Redirect on one. That's not
>> acceptable in my case as I'm using cPanel and don't want to mess with
>> the VirtualHosts if I can avoid it (in which case mod_rewrite
>> reactivation is a better option).

> Hey Peter,

> Couldn't you use a before_filter on the application controller to test the
> request?  I do something similar for an ssl requiremet for specific
> controllers like:

>     def redirect_to_ssl
>       return if request.ssl?

>       unless (request.ssl? or RAILS_ENV == 'development')
>           redirect_to(url_for(params.merge({:protocol => 'https://'})))
>       end

>     end

> Of course the before_filter is redirect_to_ssl.

> Good luck,
> andy

> --
> Andrew Stone


 
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.