默认所有页面都使用 HTTP 连接,除了 4 个页面需要使用 HTTPS

发布于 2024-12-06 11:11:49 字数 527 浏览 0 评论 0原文

我对 .htaccess 和重写规则完全陌生,我很挣扎。基本上我正在开发一个拥有数千个页面的网站,除了收集客户数据和支付过程的 4 个页面外,我需要所有页面都是 HTTP 的。

我知道我需要以下内容:

RewriteCond %{HTTPS} on
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} ^/(index\.php)?$ [NC]
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301, NC]

RewriteCond %{HTTPS} on
RewriteCond %{QUERY_STRING} ^view=(default|new(&.*)?)$ [NC]
RewriteCond %{REQUEST_URI} ^/?index\.php$ [NC]
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301, NC]

您能提供的任何帮助将不胜感激。

I am completely new to .htaccess and rewrite rules and I am struggling. Bascially I am working on a website with thousands of pages, I need all of the pages to be HTTP except for 4 pages which the customer data collection and payment process is collected over.

I know I need something along the lines of:

RewriteCond %{HTTPS} on
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} ^/(index\.php)?$ [NC]
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301, NC]

RewriteCond %{HTTPS} on
RewriteCond %{QUERY_STRING} ^view=(default|new(&.*)?)$ [NC]
RewriteCond %{REQUEST_URI} ^/?index\.php$ [NC]
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301, NC]

Any help you can provide would be greatly appeciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美胚控场 2024-12-13 11:11:49

要确保这 4 个页面始终通过 HTTPS 提供服务,请尝试此规则:

RewriteEngine On

RewriteCond %{HTTPS} =off
RewriteRule ^(cart|Cart|summary|control)\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

此规则将始终将这些页面重定向到 HTTPS(如果尚未存在):example.com/cart.phpexample.com /Cart.phpexample.com/summary.phpexample.com/control.php(所有页面都位于网站根目录中,您可以看)。如果它们有不同的 URL,则相应地调整规则。

To ensure that those 4 pages are always served via HTTPS try this rule:

RewriteEngine On

RewriteCond %{HTTPS} =off
RewriteRule ^(cart|Cart|summary|control)\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

This rule will ALWAYS redirect these pages to HTTPS if not there already: example.com/cart.php, example.com/Cart.php, example.com/summary.php, example.com/control.php (all pages are located in website root, as you can see). If they have different URLs, then adjust the rule accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文