默认所有页面都使用 HTTP 连接,除了 4 个页面需要使用 HTTPS
我对 .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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要确保这 4 个页面始终通过 HTTPS 提供服务,请尝试此规则:
此规则将始终将这些页面重定向到 HTTPS(如果尚未存在):
example.com/cart.php
、example.com /Cart.php
、example.com/summary.php
、example.com/control.php
(所有页面都位于网站根目录中,您可以看)。如果它们有不同的 URL,则相应地调整规则。To ensure that those 4 pages are always served via HTTPS try this rule:
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.