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 %{Q开发者_StackOverflow社区UERY_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.
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.
精彩评论