Forum Moderators: phranque
www.websiteA.com:80 though. Trailing port number is catered for for all other URL versions, except this one.
RewriteEngine on
#
# Externally redirect certain non-canonical hostnames to canonical hostname:
# non-www websiteA hostname
RewriteCond %{HTTP_HOST} ^websiteA\.com [NC,OR]
# FQDN-format www.websiteA.com or with appended port number
RewriteCond %{HTTP_HOST} ^www\.websiteA\.com(\.|\.?:[0-9]+)$ [NC,OR]
# www- or non-www websiteB.com
RewriteCond %{HTTP_HOST} ^(www\.)?websiteB\.com [NC]
RewriteRule ^(.*)$ http://www.websiteA.com/$1 [R=301,L]
RewriteEngine on
#
# Externally redirect all non-blank, non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.websiteA\.com)?$
RewriteRule ^(.*)$ http://www.websiteA.com/$1 [R=301,L]
RewriteEngine on
#
# Externally redirect certain non-canonical hostnames to canonical hostname, preserving http/https protocol
# non-www websiteA hostname
RewriteCond %{HTTP_HOST} ^websiteA\.com [NC,OR]
# FQDN-format www.websiteA.com or with appended port number
RewriteCond %{HTTP_HOST} ^www\.websiteA\.com(\.|\.?:[0-9]+)$ [NC,OR]
# www- or non-www websiteB.com
RewriteCond %{HTTP_HOST} ^(www\.)?websiteB\.com [NC]
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ http%2://www.websiteA.com/$1 [R=301,L]
#
# -or-
#
RewriteEngine on
#
# Externally redirect all non-blank, non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.websiteA\.com)?$
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ http%2://www.websiteA.com/$1 [R=301,L]
9.9 CONNECT
This specification reserves the method name CONNECT for use with a proxy that can dynamically switch to being a tunnel (e.g. SSL tunneling).
RewriteEngine on
#
# Externally redirect old mod_userdir-format requests to canonical hostname
RewriteCond %{HTTP_HOST} ^(www\.)?xyz\.com(\.|\.?:[0-9]+)$ [NC]
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^~adminxx/(.*)$ http%2://www.websiteA.com/$1 [R=301,L]
#
# Externally redirect certain non-canonical hostnames to canonical hostname, preserving http/https protocol
# non-www websiteA hostname
RewriteCond %{HTTP_HOST} ^websiteA\.com [NC,OR]
# FQDN-format www.websiteA.com or with appended port number
RewriteCond %{HTTP_HOST} ^www\.websiteA\.com(\.|\.?:[0-9]+)$ [NC,OR]
# www- or non-www websiteB.com
RewriteCond %{HTTP_HOST} ^(www\.)?websiteB\.com [NC]
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ http%2://www.websiteA.com/$1 [R=301,L]
# Externally redirect to force SSL/https on secure shopping cart pages
RewriteCond %{SERVER_PORT} !=443
RewriteCond $1 !\.(gif|jpe?g|png|ico|css|js)$
RewriteRule ^osc/(.*)$ https://www.domainA.com/osc/$1 [R=301,L]
#
# Externally redirect to force http on all pages except secure shopping cart pages
RewriteCond %{SERVER_PORT} =443
RewriteCond $1 !^osc/
RewriteCond $1 !^(robots\.txt|sitemap\.xml)$
RewriteCond $1 !\.(gif|jpe?g|png|ico|css|js)$
RewriteRule ^(.*)$ http://www.domainA.com/$1 [R=301,L]
# Externally redirect old mod_userdir-format requests to canonical hostname
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /~adminxx/[^\ ]*\ HTTP/
RewriteCond %{HTTP_HOST} ^(www\.)?xyz\.com(\.|\.?:[0-9]+)$ [NC]
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ http%2://www.websiteA.com/$1 [R=301,L]
yet a 301 redirect won't function right as it is looking at the same physical location on the server and would go into a loop.