Apache 通过一个url的例外重定向到HTTPS

Apache 通过一个url的例外重定向到HTTPS,apache,.htaccess,nginx,redirect,https,Apache,.htaccess,Nginx,Redirect,Https,我需要强制将所有页面重定向到https,除了一个页面。但在prod服务器上,它在无限重定向循环中失败 它忽略异常url并重定向所有url 服务器安装了apache和nginx RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{REQUEST_URI} !/novinki [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %

我需要强制将所有页面重定向到https,除了一个页面。但在prod服务器上,它在无限重定向循环中失败

它忽略异常url并重定向所有url

服务器安装了apache和nginx

RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteCond %{REQUEST_URI} !/novinki [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


RewriteCond %{HTTP:X-Forwarded-Proto} =https 
RewriteCond %{REQUEST_URI} /novinki [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
UPD

此代码在本地工作,但在prod上它强制所有页面使用https (
请求
而不是
请求

Apache配置(部分):


“服务器安装了apache和nginx”-那么你用一个来代理另一个?分享一些相关的配置细节,然后也许。您在本地开发系统上的设置是相同的,或者在主要方面(比如没有代理)是不同的?您是否启用了重写日志记录来尝试找出这样做的原因?@misorude I添加了nginx和apache配置。在我的本地机器上,我只有apache+windows,它可以根据我的需要重定向。我尝试启用重写日志-不知道这是可能的。
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteCond %{THE_REQUEST} !/novinki [NC]
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
<VirtualHost 127.0.0.1:8080>

    <FilesMatch "\.ph(p[3-5]?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>

    SetEnvIf X-Forwarded-Proto https HTTPS=on
</VirtualHost>
server {
    server_name {domain};
    charset off;
    index index.html index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/{domain}/*.conf;
    access_log /var/www/httpd-logs/{domain}.access.log;
    error_log /var/www/httpd-logs/{domain}.error.log notice;
    ssi on;
    set $root_path /var/www/roots/data/www/{domain};
    root $root_path;
    listen {ip}:80;
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @fallback;
        }
        location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
            try_files $uri $uri/ @fallback;
        }
        location / {
            try_files /does_not_exists @fallback;
        }
    }
    location @fallback {
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect http://127.0.0.1:8080 /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        access_log off;
    }
}
server {
    server_name {domain};
    ssl_certificate "/var/www/httpd-cert/roots/{domain}";
    ssl_certificate_key "/var/www/httpd-cert/roots/{domain}";
    ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
    ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
    charset off;
    index index.html index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/{domain}/*.conf;
    access_log /var/www/httpd-logs/{domain}.access.log;
    error_log /var/www/httpd-logs/{domain}.com.error.log notice;
    ssi on;
    set $root_path /var/www/roots/data/www/{domain};
    root $root_path;
    listen {ip}:443 ssl;
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @fallback;
        }
        location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
            try_files $uri $uri/ @fallback;
        }
        location / {
            try_files /does_not_exists @fallback;
        }
    }
    location @fallback {
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect http://127.0.0.1:8080 /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        access_log off;
    }
}