14 comments
Comment from: Feo [Visitor]
Feo

Very nice exapmle! And if I would like to use opposite syntax? To redirect to www-version?

11/22/07 @ 23:02
Comment from: SimonSimCity [Visitor]
SimonSimCity

This is great !!!
I’ve many problems with the .htaccess-Passwords …
If I include a picture with the WWW I had to type in my Passwords again …
Thanks for this great fix !!!

@Feo
If you want to redict “http://domain.com” to “http://www.domain.com” you need this code:

rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1

07/26/08 @ 19:47
Comment from: Kassra [Visitor]
Kassra

Where does this code go? I have a godaddy.com account for my domain and I have an A record set up posting to hosting elsewhere. Is it possible to set this up through my godaddy.com account?

01/29/09 @ 12:01
Comment from: Narayana [Visitor]
Narayana

You actually do not need the line
“RewriteCond %{HTTP_HOST} !^$”
because the second RewriteCond line that checks for the domain name already checks for an empty HTTP_HOST variable.

08/05/09 @ 08:12
traffic to your website

Can’t we just use the cpanel perm 301 redirect to accomplish the same purpose?

What are your thoughts on wildcard redirect for directories?


12/28/09 @ 06:15
traffic to your website

Forgot this one…isn’t it best policy to go “http://www.domain.com” to “http://domain.com"?

I am wondering why FEO above would want to go in the opposite directions.

Is there are good reason (besides personal preference) to do go in FEO’s direction?

Thanks for your reply!

12/28/09 @ 06:19
Comment from: Dinesh [Visitor]
Dinesh

Very nice examples, every beginner website owner asking for this code.

07/26/10 @ 08:07
Comment from: alpine mountaineer maudit review [Visitor]
alpine mountaineer maudit review

I am curious to find out what blog platform you have been using? I’m experiencing some small security issues with my latest site and I’d like to find something more risk-free. Do you have any recommendations?

12/31/10 @ 00:53
Comment from: Rokabear [Visitor]
Rokabear

Nice Examples. Finally got mine working because of them.

05/07/11 @ 04:27
Comment from: Bali Fashion [Visitor]
Bali Fashion

I wonder if this works for Wordpress multisite system?

I’m still struggling with Wordpress 3+ multisite and prefer to having www for the multisite’s main domain. Can’t find the solution yet and will appreciate if you’d be able to guide me :-).

Thanks a lot.

08/30/11 @ 16:29
Comment from: jayendra [Visitor]
jayendra

Hi,

Could you help me?

I want to redirect www.example.test.com to http://example.test.com.

I tried the solution you mentioned here but this did not work.

11/14/11 @ 12:51
Comment from: SEO Expert Company [Visitor]
SEO Expert Company

good stuff

02/05/12 @ 19:12
Comment from: Maz [Visitor]
Maz

Thanks Francois! Used the second option for handling multiple sites and it worked like a charm for me.

Excellent!

02/19/12 @ 00:30
Comment from: isimsar.com [Visitor]
isimsar.com

I tried it but it doesn’t change the address to www.domainname.com

09/03/12 @ 14:56


Form is loading...