Forum Moderators: phranque
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST}!^www\.domain\.com
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
and
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
Thanks.
Any one know the difference in between:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST}!^www\.domain\.com
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
and
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
Thanks.
Any one know the difference in between:Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]and
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
The first one says, "If not my primary domain, redirect to my primary domain" while the second one says, "If a specific secondary domain, redirect to my primary domain."
So, the first method can redirect many alternate domains and subdomains to your preferred domain, while the second method only redirects a specific domain or subdomain to your preferred domain.
BTW, posting on this board removes spaces preceding the "!" character. In order to override that behaviour, either type two spaces, or precede the "!" with Bold-Unbold or Italic-EndItalic style codes. The first method won't survive a "preview" in the post editor, while the second method will.
The same method can be used to 'break' the automatic link-making behaviour of this forum by inserting a style code between "http:" and "//".
Jim
That's because you're trying to use the code in httpd.conf, I suspect. The code above is written for use in .htaccess, so you'll need to adjust the RewriteRule accordingly.
For use in .htaccess (original, as above):
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] For use in httpd.conf, you can change it either of two ways::
RewriteRule ^[b]/[/b](.*)$ http://www.domain.com/$1 [R=301,L] RewriteRule ^(.*)$ http://www.domain.co[b]m$[/b]1 [R=301,L] Jim
Just want to clarify my understanding of these,
"If not my primary domain, redirect to my primary domain"
Is that means it will redirect www1, www2, domain.com or other to www.domain.com?
"If a specific secondary domain, redirect to my primary domain"
Is that means it just redirect a specific secondary domain such as www1.domain.com, forum.domain.com and NEVER redirect other like domain.com or [domain.com...] to www.domain.com?
Thanks again Jim.
One more question, what about if I remove the ^ as below, any effect on it?
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*)$ [domain.com...] [R=301,L]
Thanks.
I avoided modifying that part of your code simply because it did not matter, and I don't like to confuse things by introducing side-issues.
Jim