Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.domain\.net [NC]
RewriteCond %{HTTP_HOST}!^$
RewriteRule ^(.*)$ [domain.net...] [R=301,L,QSA]
This is a modification of the redirect non-www to www domain code. But it doesn't seem to work.
I would like both the www.domain.net and domain.net requests to redirect to [domain.net...] (secure).
Any suggestions please?
RewriteEngine on
#
# Skip if requested hostname is canonical (or blank) AND request is HTTPS
RewriteCond %{HTTP_HOST} ^$¦^www\.example\.net
RewriteCond %{SERVER_PORT} ^443$
RewriteRule .* - [S=1]
# Else redirect to canonical domain using HTTPS
RewriteRule (.*) https://www.example.net/$1 [R=301,L]
Replace the broken pipe "¦" characters above with solid pipes before use; Posting on this forum modifies the pipe characters.
Jim
[edited by: jdMorgan at 2:12 am (utc) on June 12, 2007]
RewriteEngine on
#
# Skip if requested hostname is canonical (or blank) AND request is HTTPS or REQUEST_URI contains excluded directory
RewriteCond %{REQUEST_URI} ^$¦^www\.example\.net/dir1
RewriteCond %{REQUEST_URI} ^$¦^www\.example\.net/dir2
RewriteCond %{HTTP_HOST} ^$¦^www\.example\.net
RewriteCond %{SERVER_PORT} ^443$
RewriteRule .* - [S=1]
# Else redirect to canonical domain using HTTPS
RewriteRule (.*) [example.net...] [R=301,L]
But it seems to hang.
RewriteEngine on
#
# Skip if requested hostname is canonical (or blank) AND request is HTTPS or REQUEST_URI contains excluded directory
RewriteCond %{HTTP_HOST} ^$¦^www\.example\.net
RewriteCond %{SERVER_PORT} ^443$
RewriteRule .* - [S=1]
# Else redirect to canonical domain using HTTPS except for dir1 and dir2
RewriteCond $1 !^(dir1¦dir2)
RewriteRule (.*) https://www.example.net/$1 [R=301,L]
Jim