简体   繁体   English

.htaccess重定向到带条件页面的https

[英].htaccess redirect to https with conditions page

I have the following .htaccess 我有以下.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]

I want all pages to be redirected to https, except /webservice and /api in those two I want it to open with both http and https. 我希望所有页面都被重定向到https,除了/ webservice和/ api之外我希望它用http和https打开。

In https requests everything works fine the problem is when I try to access http. 在https请求中,当我尝试访问http时,一切正常。

Problems 问题

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

Any idea to make it work? 有什么想让它发挥作用吗?

Change 更改

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

to

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

or 要么

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM