.htaccess 重定向至 https with condition 页面



>我有以下 .htaccess

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !(/webservice|/api)
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !.(gif|jpg|png|css|js|swf)$ index.php [L]

我希望所有页面都重定向到 https,除了/webservice 和/api,我希望它同时使用 http 和 https 打开。

在https请求中一切正常,问题是当我尝试访问http时。

问题

http://www.local.test/sub/pt-br/webservice redirect to https://www.local.test/index.php
http://www.local.test/sub/pt-br/api redirect to https://www.local.test/index.php

有什么想法让它工作吗?

更改

RewriteCond %{REQUEST_URI} !(/webservice|/api)

RewriteCond %{REQUEST_URI} !^(/webservice|/api|/sub/pt-br/webservice|/sub/pt-br/api)

RewriteCond %{REQUEST_URI} !^/webservice
RewriteCond %{REQUEST_URI} !^/sub/pt-br/webservice
RewriteCond %{REQUEST_URI} !^/api
RewriteCond %{REQUEST_URI} !^/sub/pt-br/api

最新更新