我有 Drupal 网站。
我已经检查了以下所有链接,但要么它们不重定向,要么我收到错误 - 网站有太多重定向
- https://www.drupal.org/https-information
- Redirect all the data served by https to http
- https://drupal.stackexchange.com/questions/24072/how-to-simply-make-the-whole-site-https
- http to https apache redirection
- How to redirect from HTTPS to HTTP?
- https://ilovedrupal.com/blog/redirect-http-https-apache-configuration-permanent-redirect-http-https-pages
我需要将整个网站 HTTP 重定向到 HTTPS,除了两个页面:-
- 首页 - www.hello.com
- 产品 - www.hello.com/products
下面的代码片段将整个网站重定向到 HTTPS,没有任何问题,但我需要转义主页和产品页面,为此我已经尝试了超过 10-15 种组合。
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.hello\.com*
RewriteRule ^(.*)$ https://hello.com/$1 [L,R=301]
非常感谢任何帮助。
最佳答案
您可以使用:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.hello\.com
RewriteCond %{REQUEST_URI} !^/products/?$ [NC]
RewriteRule ^(.+)$ https://hello.com/$1 [L,R=301]
关于php - 如何将整个站点从 HTTP 重定向到 HTTPS(Drupal 站点中除了 2 个页面之外)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37098643/