HTaccess Redirect Good For Only One Page?

Sitepoint members,
I just learned from my webhost that when code like this
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ “http\:\/\/example\.com\/” [R=301,L]

was put in my htaccess (and I used it for other sites) it only works for the home page. My webhot didn’t know of a way to remove www for all pages with one chunk of code that applies to all pages. I would think that in all the programming going on over the last 10 years and with the global nature of the htaccess file that this problem would have been solved. This seems to be a big hole in the possibility for life without www. Maybe not, I found a well known website where you can add www to any of their web address, hit enter, and the www will be removed form the address field. What is the htaccess code to do this, or do you think the site actually has code in their htaccess address by address for every one of their pages?

Thanks,

Chris

I suppose your webhost also doesn’t know how to use Google. My advice: Don’t rely on your webhost for any more htaccess code. They don’t seem to be good at it.

Fortunately, it’s a small and simple change to make it work for all pages.

RewriteCond %{HTTP_HOST} ^www\\.example\\.com$ 
RewriteRule ^[COLOR="#FF0000"](.*)[/COLOR]$ http://example.com/[COLOR="#FF0000"]$1[/COLOR] [R=301,L]

Jeff,
That code worked great. I guess I’m at fault some for not thinking of that simple phrse you used in google. No doubt something is off center somewhat when my webhost didn’t know the answer to this common need, even after working on it for a while.

The computer video via the blue google link was interesting. I never saw anything like that before, other than with an old Lotus program. How did you do that?

Thanks Jeff

Maybe it’s discouraged because it uses more processing power.