They both do the same thing, but neither of them are correct. You are redirecting the www domain to the same subdomain and domain which accomplishes nothing. Every page would generate a 301 status code, rather than a proper 200 status code.
When you entered the sample code shown above, you may entered it incorrectly because that code will not do what you are trying to accomplish.
This is the correct version
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainname\.com$ [NC]
RewriteRule ^(.*)$ http://www.domainname.com/$1 [R=301,L]
This version redirects a non-www domain to a www subdomain and a domain.
[NC] is supposed to handle mixed case characters (case insensitive) , but it appears to work the same without it. It is possible that it is no longer required with newer versions of Apache. Someone else may know more about the history of this.
Options +FollowSymLinks is required by some servers. The majority do not need it. I have actually never seen a server configuration that required it.
RewriteBase / may not normally be required, but use it if the 301 redirect does not work. It states where the relative root directory for the .htaccess file resides. If the .htaccess file and a forum are in a directory called "forum", then the RewriteBase would be /forum/.
Last edited by TopDogger; 26 July, 2009 at 15:07 PM.
"It's inexcusable for scientists to torture animals; let them make their experiments on journalists and politicians." -Henrik Ibsen
Bookmarks