# Redirects with mongrel (dropping the www. from a url)

**URL:** <https://www.ruby-forum.com/t/redirects-with-mongrel-dropping-the-www-from-a-url/117428>\
**Category:** Mongrel\
**Created:** [October 16, 2007, 8:08pm UTC](https://www.ruby-forum.com/t/redirects-with-mongrel-dropping-the-www-from-a-url/117428 "2007-10-16T20:08:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [October 16, 2007, 8:08pm UTC](https://www.ruby-forum.com/t/redirects-with-mongrel-dropping-the-www-from-a-url/117428/1 "2007-10-16T20:08:13Z")

</div>

Hi All,

I have a rails app running on an apache virtual host with mongrel that  
i want to set up a redirect from [www.someapp.com](http://www.someapp.com) to [someapp.com](http://someapp.com)  
(dropping  
the www.)

I have tried doing this in apache using a rewrite rule (below) which  
worked before when the app was written in php.

Redirect [http://www.soccertackle.com/](http://www.soccertackle.com/) [http://soccertackle.com](http://soccertackle.com)  
RewriteEngine on  
RewriteCond %{HTTP\_HOST} !^soccertackle.com [NC]  
RewriteCond %{HTTP\_HOST} !^$  
RewriteRule ^/(.\*) [http://soccertackle.com/$1](http://soccertackle.com/$1) [L,R]

Now the app has been completely re written in rails using mongrel &  
apache (i don’t really understand much about web servers but mongrel  
set up was nice and simple). However my redirect does not work any  
longer. I cant seem to find any information on the web (which would  
suggest i’m looking in the wrong places).

can anyone suggest a solution to my problem or point me in the right  
direction?  
please be gentle, as i mentioned before servers are not my strong  
point.

Thank you.

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [October 16, 2007, 8:58pm UTC](https://www.ruby-forum.com/t/redirects-with-mongrel-dropping-the-www-from-a-url/117428/2 "2007-10-16T20:58:53Z")

</div>

Not enough info to debug here, and whether it’s PHP vs. Mongrel shld be  
irrelevant.

Short of that, here’s something that works. If I state that the backend  
is Mongrel/Nitro will the moderator consider this on-topic? 🙂

\<VirtualHost \*:80\>  
ServerName [soccertackle.com](http://soccertackle.com)  
ServerAlias [www.soccertackle.com](http://www.soccertackle.com)  
RewriteEngine On

RewriteCond %{SERVER\_NAME} [www.sockertackle.com](http://www.sockertackle.com)  
RewriteRule ^.\*$ [http://sockertackle.com$1](http://sockertackle.com$1) [L,R]
