Welcome Guest | Login

Getting rid of www.

Hi,

I want to permanently redirect the www.example.com form of my domain into the example.com form.

I tried these recommended .htaccess lines but they dont work for me:

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

There are some other Rewrite rules and conditions in the file and I tried placing these lines before and after them. Does not work either way.

Any suggestions?

2008-04-24 05:04 PM

Hi Edgerunner,

I have given the proper rewrite rules for your domain in the vhost entry and now all the requests to www.example.com is rewriting to example.com. You can use the following rewrite rules to rewrite www.example.com to example.com.

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

Since you are using mongrel the rewrite rules should be in the apache configuration file.

2008-04-24 06:17 PM

Ok thanks it works now.

What I understand is:
1. The rules were correct to begin with
2. They were just in the wrong file
3. .htaccess has no effect when you are using mongrel
4. I dont have access to the apache configuration file
5. You do, so I have to ask when I need to change something

Are these correct?

2008-04-24 06:25 PM

Yes, thats true..

2008-04-24 08:24 PM

Regards,
Rahul

Hello Guest! In order to post you must be an active client with us, please log in or sign up.