Force app to use www only

Hi everyone,

I want to go live with my application. But something is wrong with my
site when using www.domain.com or domain.com. It seems that it use
different instances of the app and create different sessions.

How can I configure my app to redirect to www.domain.com when someone
calls domain.com?

Thanks in advance

Adam

Personally, I redirect www.example.com to example.com (example.com is
already a web site, no need for redundancy and it makes hard then for
people
to assimilate blog.example.com (so, a blog is not a web site then?) or
newyork.example.com (where’s www?) but I digress). I redirect at the
Apache
level doing:

<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.org www.example.org
Redirect / http://example.com/

The trailing slash in “Redirect / http://example.com/” is important :wink:

On Sun, Nov 8, 2009 at 23:19, Adam M.
[email protected]wrote:

Thanks in advance

Adam

Posted via http://www.ruby-forum.com/.


J. Pablo Fernández [email protected] (http://pupeno.com)

Adam M. wrote:

Hi everyone,

I want to go live with my application. But something is wrong with my
site when using www.domain.com or domain.com. It seems that it use
different instances of the app and create different sessions.

How can I configure my app to redirect to www.domain.com when someone
calls domain.com?

Thanks in advance

Adam

Hi,
In .htaccess you specify the rewrite url rule to redirect
domain.com to www.domain.com
Place below code in .htaccess

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

Thanks,
Priyanka P.

Priyanka P. wrote:

Adam M. wrote:

Hi everyone,

I want to go live with my application. But something is wrong with my
site when using www.domain.com or domain.com. It seems that it use
different instances of the app and create different sessions.

How can I configure my app to redirect to www.domain.com when someone
calls domain.com?

Thanks in advance

Adam

Hi,
In .htaccess you specify the rewrite url rule to redirect
domain.com to www.domain.com
Place below code in .htaccess

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

Thanks,
Priyanka P.

Thanks, I realized it with a .htaccess. The vhost configuration sent me
in a loop.

Cheers