将大多数网站 https 重定向到 http 除了一个部分


Redirecting most of site https to http apart from one section

我有一个网站,我们只希望https在计费部分工作,因为这是目前唯一设置为使用它的部分,所以我们想确保如果有人去https网站的任何其他部分,那么他们将被重定向到http等效部分。

目前我们只对一个页面执行此操作,这是来自站点根目录的当前.htaccess文件:

RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteRule ^auction_search.php$ http://%{HTTP_HOST}/auction_search.php [R=301,L]
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteRule ^(.*),(.*)$ $2.php?rewrite_params=$1&page_url=$2
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR] 
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR] 
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR] 
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2}) 
RewriteRule ^(.*)$ index.php [F,L]
RewriteRule ^stores/([0-9a-z.-]+)/?$ shop.php?shop_id=$1 [L,QSA,NC]
RewriteRule ^stores/([0-9a-z.-]+)/ajax_files/watch_item'.php$ ajax_files/watch_item.php [L,QSA,NC]
RewriteRule ^stores/([0-9a-z.-]+)/ajax_files/save_field'.php$ ajax_files/save_field.php [L,QSA,NC]
RewriteRule ^stores/([0-9a-z.-]+)/images/form-cb-icons'.png$ images/form-cb-icons.png [L,NC]
RewriteRule ^group-break/([0-9]+)/[0-9a-z.-]+/?$ group_break.php?cb_id=$1 [L,NC]
RewriteRule ^group-breaks/([a-z]+)-[a-z-]+/?$ group_breaks.php?tab=$1 [L,NC]

正如您在顶部附近看到的,有这个:

RewriteCond %{HTTPS} =on
RewriteRule ^auction_search.php$ http://%{HTTP_HOST}/auction_search.php [R=301,L]

因此,我们想更改此设置,以便将所有https请求重定向到等效的http页面,除了内部的任何内容,包括从主根目录运行的目录billing,即; 它的位置是:www.mysite.com/billing/

编辑:它实际上也应该允许在https上查看以下扩展:.png,.jpg,.jpeg,.gif,.css.js

所以只是想知道我们如何改变我们必须做我们想做的事的现行规则?

您可以在同一位置使用此规则:

RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !'.(jpe?g|gif|bmp|png|ico|js|css)$ [NC]
RewriteRule !^billing(/.*)?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC,NE]