Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在https情况下忽略Apache RewriteCond_Apache_.htaccess_Mod Rewrite_Https - Fatal编程技术网

在https情况下忽略Apache RewriteCond

在https情况下忽略Apache RewriteCond,apache,.htaccess,mod-rewrite,https,Apache,.htaccess,Mod Rewrite,Https,我必须从一个域重定向到另一个域。这两个域都启用了http和https协议。为了映射http和https,我在conf文件中尝试了各种组合,如下所示: #RewriteCond%{HTTPS}=on #重写cond%{SERVER_PORT}^443$ #重写规则^(+)$-[env=askapache:https] #RewriteCond %{HTTPS} !=on #RewriteRule ^(.+)$ - [env=askapache:http] RewriteCond %{SERVER_

我必须从一个域重定向到另一个域。这两个域都启用了http和https协议。为了映射http和https,我在conf文件中尝试了各种组合,如下所示: #RewriteCond%{HTTPS}=on #重写cond%{SERVER_PORT}^443$ #重写规则^(+)$-[env=askapache:https]

#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.+)$ - [env=askapache:http]
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.+)$ - [env=askapache:%2]

RewriteCond %{HTTP_HOST} ^([www.]+)?test-redirect\.com$ [NC]  
RewriteRule  ^(.*)$ http%{ENV:askapache}//amit.test.com/content/test/category/6  [L]

#RewriteCond %{HTTP_HOST} ^([www.]+)?test-redirect\.com$ [NC]  <BR> 
#RewriteCond %{HTTPS} !on
#RewriteRule .? http://amit.test.com/content/test/category/6 [L]`
#重写cond%{HTTPS}=在…上
#重写规则^(+)$-[env=askapache:http]
重写cond%{SERVER_PORT}s^(443(s)|[0-9]+s)$
重写规则^(+)$-[env=askapache:%2]
重写cond%{HTTP_HOST}^([www.]+)?测试重定向\.com$[NC]
重写规则^(.*)$http%{ENV:askapache}//amit.test.com/content/test/category/6[L]
#重写cond%{HTTP_HOST}^([www.]+)?测试重定向\.com$[NC]
#重写cond%{HTTPS}!在…上 #重写规则。?http://amit.test.com/content/test/category/6 [L]`
但每次都会跳过/忽略https条件。也没有重写日志的功能。我在网上看到了很多例子。但不明白为什么它没有检测到https?http工作得非常好。

  • 对于https和http,重写日志很可能位于两个不同的位置。您可以尝试使用
    HTTP_AA
    而不是使用“askapache”作为环境名称。前缀HTTP_anywhere是一种更安全的方法,可以确保var可用,因为某些设置不允许自定义var以HTTP_以外的任何东西开头,因为HTTP_通常表示HTTP头

  • 确保您的https端口实际上是443,否则需要更改代码

  • 通过尝试这里的第一个和第二个方法,确保您的mod_rewrite
    代码可以工作:如果使用第一个示例无法工作,则需要首先使用该规则使其工作

  • 尝试使用SetEnvIfNoCase指令或使用

    SetEnv HTTP_AA

  • 验证SSL和非SSL的vhost/httpd.conf设置,如文档根目录和选项,以及SSLOptions的允许覆盖、日志和可能的stdenvvar

  • 使用只执行
    printenv
    mod\u includes
    构建shtml文件。然后查看ssl和非ssl输出,并特别注意前缀为
    的var重定向
    ,显然要确保
    HTTP\u AA
    var在
    printenv
    输出中正确显示。或者您可以在askapache站点上使用cgi脚本或shtml示例

  • 别忘了

或者试试这个

    Options +FollowSymLinks +ExecCGI

    # Set var now to try to try to have it availabe for mod_rewrite
    SetEnv HTTP_AA

    RewriteEngine On
    RewriteBase /

    # HTTP_AA is set to either s or is blank
    RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
    RewriteRule ^(.+)$ - [env=HTTP_AA:%2]

    # if host not new domain, its old so redirect both http/https to new
    RewriteCond %{HTTP_HOST} !^amit\.example\.com$ [NC]
    RewriteRule  .* http%{ENV:HTTP_AA}://amit.example.com/content/test/category/6  [R=301,L]