Forum Moderators: phranque
Appears to be working, tested in all browsers, anything amiss here?
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.example\.com
## For included files - JS, CSS, etc. stored in "includes"
RewriteCond %{REQUEST_URI}!\/includes\/
RewriteCond %{HTTPS}!^443$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Wouldn't this be more prudent if the task is only to direct .net and .org to .com? (above code was with WITH spaces before! of course . . . )
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} (www\.)*example\.net
RewriteCond %{HTTP_HOST} (www\.)*example\.org
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
The https is only used once the visitor is actually in the site.
RewriteEngine On
#
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com
## For included files - JS, CSS, etc. stored in "includes"
RewriteCond %{REQUEST_URI} !/includes/
RewriteCond %{[b]SERVER_PORT[/b]} !^443$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteEngine On
#
RewriteCond %{HTTP_HOST} (www\.)?example\.net [b][OR][/b]
RewriteCond %{HTTP_HOST} (www\.)?example\.org
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
[edited by: jdMorgan at 9:54 pm (utc) on June 7, 2007]
[edit - scratch this]But for whatever reason, the redirect does not work.[/scratch]
(It works perfectly, was checking an .htaccess in a different directory. Doh.)
Does this make better sense for the task, or no? I'm always wary of doing an "everything except" in my programming because there may be something in that everything I hadn't thought of.
The %{HTTPS}!^443$ I picked up from some code around here . . . somewhere . . . case in point. :-)