How to do no-www to www to all Inside page of a site?

i used the following code in .hactess. but it doesn’t work.


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

when i access

 http://example.com/1.html 

it doesn’t redirect to

http://www.example.com/1.html

it redirect to http://example.com

http://example.com/news.html

to

http://www.example.com/news.html

,it redirect to http://example.com

Try this:


RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\\.example\\.com$ [NC]
RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]

Ralph,

Thanks. That’s my preferred version of the same but RED’s code should work so there is something else going on which he is not showing (perhaps a Redirect / http://www.example.com).

Regards,

DK

[ot]

Heh heh, I figured I would keep you happy if I quoted your own code. :lol: [/ot]

:smiley: :smiley: :smiley:

Unfortunately, you’re not built right to keep me happy!

:rofl: :rofl: :rofl:

Regards,

DK

Off Topic:

Now you’re sounding like my wife. :shifty:

PS: I learned at university that a sure way to get good marks was to quote my lecturers in my essays and agree with their views and theories. :smiley:

Ralph,

I think I shouldn’t comment about your wife’s opinion of you - at least what she’s telling you! :nono:

As for the profs, wasn’t it more fun to quote an authority with an opposing view and watch the tirade? :rofl:

Regards,

DK

[ot]

Nah, I couldn’t be bothered with the confrontation. It was easier to keep them happy and get good grades. :smiley:

(I didn’t enjoy uni much, and just wanted to get it over with. The few times I did stir up trouble, it wasn’t very fun. I ended by doing a teaching course, and I tore apart some of their ridiculous teaching theories, and they threatened to fail me. Because I just wanted the piece of silly paper, I kept my mouth shut after that.)[/ot]