1. rewritecond %{http_host} ^nadlerzforum.com [nc] rewriterule ^(.*)$ http://www.nadlerzforum.com/$1 [r=301,nc] Code (markup): 2. RewriteCond %{HTTP_HOST} !^www\.nadlerzforum\.com$ RewriteRule (.*) http://www.nadlerzforum.com/$1 [R=301,L] Code (markup): 3. RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] Code (markup): 4. RewriteCond %{HTTP_HOST} ^nadlerzforum.com [NC] RewriteRule ^(.*)$ http://www.nadlerzforum.com/$1 [L,R=301] Code (markup): All of this 4 codes, works in my server. I'm not good in apache thing, my question is.,,. What is the best and right code to use? Thanks!
First one is good to use: rewritecond %{http_host} ^nadlerzforum.com [nc] rewriterule ^(.*)$ http://www.nadlerzforum.com/$1 [r=301,nc] However, others also works on your server but above format is most recommended by most of the webmasters. I also uses the same code on all of my websites
Lately I'm using this code: With \.com What is the difference with the first code and the second one?
The first code says that if the requested URL start with nadlerzforum.com, redirect it to http://www.nadlerzforum.com and the second rule says that if URL nadlerzforum.com not starting with www. then redirect it to www version.