Forum Moderators: phranque
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
I just noticed my ip address does not redirect properly...how would I add the IP Address properly?
I've seen some code to do it, but that doesn't have the above code to handle example.com->www.example.com and I don't want the commands to step on each other.
Thanks.
[edited by: jdMorgan at 4:18 am (utc) on June 11, 2007]
[edit reason] example.com [/edit]
1. Best practices for readability (I type stuff in my "style" by habit).
2. So it will work properly now -- or later when you add more rules. (The [NC] flag with (only) a ".*" pattern is useless, and [L] tells the rewrite engine to stop for this pass through .htaccess if the rule is invoked.)
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim