Forum Moderators: phranque
#---primary virtualhost
Servername www.maindomain.com
# (deleted serveralias)
...
#
#---second virtualhost
Servername maindomain.com
# (deleted serveralias)
RewriteEngine on
RewriteRule ^/(.*) http://www.maindomain.com/$1 [R=301]
...
#--- Single virtualhost with serveralias
Servername www.maindomain.com
Serveralias maindomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.maindomain\.com)?$
RewriteRule ^/(.*) http://www.maindomain.com/$1 [R=301]
...
Redirect 301 / http://www.maindomain.com/
RewriteRule ^/entire/directory-path/page.html$ http://www.example.com/other-page.html [R=301,L] RewriteRule ^/directory-path/page.html$ http://www.example.com/other-page.html [R=301,L] RewriteRule ^entire/directory-path/page.html$ http://www.example.com/other-page.html [R=301,L] RewriteRule ^directory-path/page.html$ http://www.example.com/other-page.html [R=301,L] this disables anything below the main page - any url that doesn't have the www in it, so that doesn't work.
# www.example.com/.htaccess
#
Options +FollowSymlinks
RewriteEngine on
#
# Externally redirect all requests for non-blank non-canonical hostnames to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Options +FollowSymLinks -Indexes -MultiViews
# www.example.com/.htaccess
#
Options +FollowSymlinks -Indexes -MultiViews
RewriteEngine on
#
# Externally redirect all requests for non-blank non-canonical hostnames to canonical hostname
RewriteCond %{HTTP_HOST} !^((www|your-other-subdomain-name-here)\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]