我有一个重写规则.htaccess
,将我们的网站重定向到HTTPS
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我需要打开一个URL才能同时使用HTTP和HTTPS(http://www.myhost.com/api
和https://www.myhost.com/api
)。我该如何修改我的上述代码
尝试以下规则,
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/support/registration_service
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
上面的规则不包括将uri/api
强制设置为https,因此您可以同时使用www.myhost.com/api
这两种方案。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句