Apache HttAccess URL重定向适用于http而不是所有https

Apache HttAccess URL重定向适用于http而不是所有https,apache,.htaccess,redirect,mod-rewrite,Apache,.htaccess,Redirect,Mod Rewrite,htaccess和重定向方面的新手,我希望有人能帮我解决这个问题。目前,所有http URL都正确重定向。例如,如果你去otherdomain.com,它会带你去maindomian.com 这目前不适用于所有https链接 例如: http-www和非www.otherdomain.com/blog都将重定向到 这正是我所需要的,但一旦我使用https,它就会执行以下操作: https-www和非www-otherdomain.com/blog都将保留在https-otherdomain.co

htaccess和重定向方面的新手,我希望有人能帮我解决这个问题。目前,所有http URL都正确重定向。例如,如果你去otherdomain.com,它会带你去maindomian.com

这目前不适用于所有https链接

例如: http-www和非www.otherdomain.com/blog都将重定向到

这正是我所需要的,但一旦我使用https,它就会执行以下操作:

https-www和非www-otherdomain.com/blog都将保留在https-otherdomain.com/blog域上

这是错误的,因为它需要转到主网站的博客页面。但是,如果我在页面上手动添加重定向,所有http和https URL都可以工作: 例如。 www和非www 将重定向到 将重定向到

这是Drupal 7,以下是我目前拥有的代码:

Redirect /newpage https://www.mainwebsite.com/welcome RewriteEngine on RewriteBase / # Force HTTPS RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # Remove trailing slash RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^mainwebsite.com$ [NC] RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Set "protossl" to "s" if we were accessed via https://. This is used later # if you enable "www." stripping or enforcement, in order to ensure that # you don't bounce between http and https. RewriteRule ^ - [E=protossl] RewriteCond %{HTTPS} on RewriteRule ^ - [E=protossl:s] # Make sure Authorization HTTP header is available to PHP # even when running as CGI or FastCGI. RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Pass all requests not referring directly to files in the filesystem to # index.php. Clean URLs are handled in drupal_environment_initialize(). RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L] 重定向/新建页面https://www.mainwebsite.com/welcome 重新启动发动机 重写基/ #强制HTTPS 重写条件%{HTTPS}关闭 重写规则(.*)https://%{HTTP_HOST}%{REQUEST_URI}[R=301,L] #删除尾部斜杠 重写规则^(.*)/$https://%{HTTP_HOST}/$1[R=301,L] RewriteCond%{HTTP_HOST}^mainwebsite.com$[NC] 重写规则^https://www.%{HTTP_HOST}%{REQUEST_URI}[L,R=301] #如果通过https://访问我们,请将“protossl”设置为“s”。这将在以后使用 #如果您启用“www.”剥离或强制执行,为了确保 #您不会在http和https之间跳转。 重写规则^-[E=protossl] 在上重写cond%{HTTPS} 重写规则^-[E=protossl:s] #确保授权HTTP头对PHP可用 #即使是作为CGI或FastCGI运行。 重写规则^-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}] #将所有不直接引用文件系统中文件的请求传递给 #index.php。干净的URL在drupal_环境_initialize()中处理。 重写cond%{REQUEST_FILENAME}-F 重写cond%{REQUEST_FILENAME}-D 重写cond%{REQUEST_URI}=/图标文件 重写规则^index.php[L] 知道如何从https otherdomain.com获取任何url以转到mainwebsite.com吗?任何帮助都将不胜感激

RewriteEngine on
RewriteCond %{HTTP_HOST} ^othersite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.othersite.com [NC]
RewriteRule ^(.*)$ https://www.mainwebsite.com/$1 [L,R=301,NC]
这将重定向所有请求,而不仅仅是/blog

如果您只想重定向/blog,那么我会稍微调整重写规则

RewriteRule ^blog/?$ http://www.newsite.com/blog [L,R=301,NC]
请就本案提出建议: