ME,
Let me add a welcome to SitePoint, too!
You tried
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]
and it didn't work? Did you test that you have mod_rewrite enabled (as well as .htaccess)? The test is at the top of the page under Test.
Alternatively,
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]
will do the same thing. Both work.
As for your other code:
Code:
Options +FollowSymLinks
# Already in the httpd.conf
RewriteEngine on
RewriteBase /
# Undoes a mod_alias redirection and, here, is superfluous
RewriteCond %{http_host} ^blahblahelectric.com$ [nc]
RewriteRule ^(.*)$ http://www.blahblahelectric.com/$1 [r=301,nc,L]
# while it doesn't make sense to create an atom duplicating an Apache variable,
# this, too, will work.
# However, because {REQUEST_URI} is case sensitive,
# the No Case flag is wrong.
# Additionally, while it's strictly technique, it's better
# to use CAPS for Apache variables and flags.
Regards,
DK
Bookmarks