Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] [edited by: jdMorgan at 6:05 pm (utc) on May 10, 2010]
[edit reason] example.com [/edit]
RewriteEngine on
#
# Externally redirect all HTTP requests for SSL pages to HTTPS
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^((booking|extranet)/.*)$ https://example.com/$1 [R=301,L]
#
# Externally redirect all HTTPS requests for non-SSL pages to HTTP, except for
# objects (e.g. images, css, JS files) shared between SSL and non-SSL pages.
RewriteCond %{SERVER_PORT} =443
RewriteCond $1 !^(booking|extranet)/
RewriteCond $1 !\.(gif|jpe?g|css|js)$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect all non-blank non-canonical hostname requests to
# the canonical hostname, preserving requested HTTP/HTTPS protocol
# (Handles object requests not already redirected above)
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+s)$
RewriteRule ^(.*)$ http%2://www.examnple.com/$1 [R=301,L]
RewriteEngine on
#
# Externally redirect all HTTP requests for SSL pages to HTTPS
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^((booking|extranet)/.*)$ https:[b]//www.ex[/b]ample.com/$1 [R=301,L]
#
# Externally redirect all HTTPS requests for non-SSL pages to HTTP, except for
# objects (e.g. images, css, JS files) shared between SSL and non-SSL pages.
RewriteCond %{SERVER_PORT} =443
RewriteCond $1 !^(booking|extranet)/
RewriteCond $1 !\.(gif|jpe?g|css|js)$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect all non-blank non-canonical hostname requests to
# the canonical hostname, preserving requested HTTP/HTTPS protocol
# (Handles object requests not already redirected above)
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(.*)$ http%2://www.examnple.com/$1 [R=301,L]
RewriteCond %{REMOTE_ADDR} =12.34.56.78
RewriteRule ^ - [S=3]
[edited by: jdMorgan at 4:40 pm (utc) on May 18, 2010]
RewriteEngine on
# COND1: Externally redirect all HTTP requests for SSL pages to HTTPS
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^((ssltest1|ssltest2)/.*)$ https://example.com/$1 [R=301,L]
# COND2: Externally redirect all HTTPS requests for non-SSL pages to HTTP, except for
# objects (e.g. images, css, JS files) shared between SSL and non-SSL pages.
RewriteCond %{SERVER_PORT} =443
RewriteCond $1 !^(ssltest1|ssltest2)/
RewriteCond $1 !\.(gif|jpe?g|css|js)$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# COND3: Externally redirect all non-blank non-canonical hostname requests to
# the canonical hostname, preserving requested HTTP/HTTPS protocol
# (Handles object requests not already redirected above)
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(.*)$ http%2://www.example.com/$1 [R=301,L]
# COND4: REWRITES ALL http://example.com/ to http://www.example.com/
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] [edited by: jdMorgan at 4:42 pm (utc) on May 18, 2010]
[edit reason] Please use example.com only. [/edit]
RewriteEngine on
# COND1: Externally redirect all HTTP requests for SSL pages to HTTPS
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^((ssltest1|ssltest2)/.*)$ https:// www.my-example.de/$1 [R=301,L]
# COND2: Externally redirect all HTTPS requests for non-SSL pages to HTTP, except for
# objects (e.g. images, css, JS files) shared between SSL and non-SSL pages.
RewriteCond %{SERVER_PORT} =443
RewriteCond $1 !^(ssltest1|ssltest2)/
RewriteCond $1 !\.(gif|jpe?g|css|js)$
RewriteRule ^(.*)$ http:// www.my-example.de/$1 [R=301,L]
# COND3: Externally redirect all non-blank non-canonical hostname requests to
# the canonical hostname, preserving requested HTTP/HTTPS protocol
# (Handles object requests not already redirected above)
RewriteCond %{HTTP_HOST} !^(www\.my-example\.de)?$ [NC]
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(.*)$ http%2:// www.my-example.de/$1 [R=301,L] [edited by: jdMorgan at 4:43 pm (utc) on May 18, 2010]
[edit reason] Corrected as noted below. [/edit]