Skip to main content
added 357 characters in body
Source Link
Ace
  • 814
  • 3
  • 10
RewriteCond %{HTTP_HOST} *!^www*.url\.com [NC]

RewriteRule (.*) http://www.url.com/$1 [L,R=301]]

The above two expressions tells apache to examine the host the visitor is accessing. The exclamation point (!) in front of www.url.com negates the comparison, saying, “If the host IS NOT www.url.om, then perform RewriteRule.” In our case RewriteRule redirects them to www.url.com while preserving the exact file they were accessing in a back-reference.

RewriteCond %{HTTP_HOST} *!^www*.url\.com [NC]

RewriteRule (.*) http://www.url.com/$1 [L,R=301]]
RewriteCond %{HTTP_HOST} *!^www*.url\.com [NC]

RewriteRule (.*) http://www.url.com/$1 [L,R=301]]

The above two expressions tells apache to examine the host the visitor is accessing. The exclamation point (!) in front of www.url.com negates the comparison, saying, “If the host IS NOT www.url.om, then perform RewriteRule.” In our case RewriteRule redirects them to www.url.com while preserving the exact file they were accessing in a back-reference.

Source Link
Ace
  • 814
  • 3
  • 10

RewriteCond %{HTTP_HOST} *!^www*.url\.com [NC]

RewriteRule (.*) http://www.url.com/$1 [L,R=301]]