Forum Moderators: phranque
1.
RewriteCond %{HTTP_HOST} ^webmasterworld.com [NC]
RewriteRule ^(.*) http://www.webmasterworld.com/$1 [L,R=301]
2.
RewriteCond %{HTTP_HOST} ^webmasterworld.com [NC]
RewriteRule ^(.*)$ http://www.webmasterworld.com/$1 [L,R=301]
Note: '$' in 2nd example.
1.
RewriteCond %{HTTP_HOST} ^111.111.1.2 [NC]
RewriteRule ^(.*) http://www.webmasterworld.com/ [L,R=301]
2.
RewriteCond %{HTTP_HOST} ^111.111.1.2 [NC]
RewriteRule ^(.*)$ http://www.webmasterworld.com/ [L,R=301]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L] [edited by: g1smd at 9:21 pm (utc) on Oct 19, 2011]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Note: '$' in 2nd example.
Why? Please explain the difference.
It works but doesn't redirect URLs with port number. Any solution?
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [OR]
RewriteCond %{HTTP_HOST} ^([1-2][0-9][0-9])\.* [OR]
RewriteCond %{HTTP_HOST} ^([1-9][0-9])\.*
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RedirectMatch 301 /subdomain/(.*) http://www.subdomain.example.com/$1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com
RewriteRule ^(.*)$ http://www.subdomain.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^([1-2][0-9][0-9])\.* [OR]
RewriteCond %{HTTP_HOST} ^([1-9][0-9])\.*