重定向通过延长htaccess的 [英] Redirect extension through htaccess
问题描述
我要重定向所有的COM扩展为组织的扩展,即使他们是HTTPS。这是我迄今为止...
I want to redirect all "com" extensions to "org" extensions, even if they are https. This is what I have so far...
RewriteCond %{HTTP_HOST} domain.com$ [NC]
RewriteRule .* https://www.domain.org [R=301,L]
的问题是,这仅重定向,如果它为http。我怎么也重定向,如果它是一个HTTPS域? 任何帮助将是AP preciated。谢谢了。
The problem is, this only redirects if it is "http". How can I also redirect if it is an https domain? Any help would be appreciated. Thank You Much.
推荐答案
尝试:
RewriteCond %{HTTP_HOST} domain.com$ [NC]
RewriteCond %{HTTPS}:s (on:(s)|off:s)
RewriteRule .* http%2://www.domain.org [R=301,L]
第二个条件中的事件 HTTPS
创建一个捕获组是上,否则,就没有捕获组。在S被捕获,然后backreferenced使用%2
。
The second condition creates a capture group in the event that HTTPS
is "on", otherwise, there is no capture group. The "s" is captured and then backreferenced using %2
.
此外,您可以通过更改重写规则行重定向的URI,以及:
Additionally, you can redirect the URI as well by changing the rewrite rule line to:
RewriteRule ^(.*)$ http%2://www.domain.org/$1 [R=301,L]
这篇关于重定向通过延长htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!