2017-07-15 66 views
0

我搜索并搜索了互联网,似乎没有任何东西可以为我工作。 我有一个启用了SSL的网站。我的托管服务提供商启用了SNI,我的支付网关公司不接受。为此,他们要求我将1个网页重定向到HTTP而不是HTTPS。将1个网页重定向到HTTP而不是HTTPS

当前失败的URL是:https://MYDOMAIN.co.uk/wc-api/MDS_Worldpay_Gateway/ 此URL应该重定向到HTTP。

如果有人可以建议我需要插入到我的.htaccess文件,它将不胜感激。我花了几个月的时间试图弄清楚这一点。

提前致谢!

这是目前我的.htaccess文件的内容:

# BEGIN W3TC Browser Cache 
<IfModule mod_deflate.c> 
     AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.presentation application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf application/vnd.ms-opentype audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel 
    <IfModule mod_mime.c> 
     # DEFLATE by extension 
     AddOutputFilter DEFLATE js css htm html xml 
    </IfModule> 
</IfModule> 
<FilesMatch "\.(html|htm|rtf|rtx|svg|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|TXT|XSD|XSL|XML)$"> 
    <IfModule mod_headers.c> 
     Header append Vary User-Agent env=!dont-vary 
    </IfModule> 
</FilesMatch> 
<FilesMatch "\.(bmp|class|doc|docx|eot|exe|ico|webp|json|mdb|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|pot|pps|ppt|pptx|svg|svgz|swf|tif|tiff|ttf|ttc|_ttf|wav|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|BMP|CLASS|DOC|DOCX|EOT|EXE|ICO|WEBP|JSON|MDB|MPP|OTF|_OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|POT|PPS|PPT|PPTX|SVG|SVGZ|SWF|TIF|TIFF|TTF|TTC|_TTF|WAV|WRI|WOFF|WOFF2|XLA|XLS|XLSX|XLT|XLW)$"> 
    <IfModule mod_headers.c> 
     Header unset Last-Modified 
    </IfModule> 
</FilesMatch> 
# END W3TC Browser Cache 
# BEGIN W3TC Page Cache core 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteCond %{HTTPS} =on 
    RewriteRule .* - [E=W3TC_SSL:_ssl] 
    RewriteCond %{SERVER_PORT} =443 
    RewriteRule .* - [E=W3TC_SSL:_ssl] 
    RewriteCond %{HTTP:Accept-Encoding} gzip 
    RewriteRule .* - [E=W3TC_ENC:_gzip] 
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC] 
    RewriteRule .* - [E=W3TC_PREVIEW:_preview] 
    RewriteCond %{REQUEST_METHOD} !=POST 
    RewriteCond %{QUERY_STRING} ="" 
    RewriteCond %{REQUEST_URI} \/$ 
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC] 
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f 
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L] 
</IfModule> 
# END W3TC Page Cache core 
# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 

# BEGIN EWWWIO 

# END EWWWIO 

回答

0

尝试(与RewriteEngine叙述在您IfModule内):

RewriteCond %{HTTPS} on 
RewriteRule ^wc-api/MDS_Worldpay_Gateway/.*$ http://%{HTTP_HOST}%{REQUEST_URI} 

对于不区分大小写的匹配尝试:

RewriteCond %{HTTPS} on 
RewriteRule ^wc-api/MDS_Worldpay_Gateway/.*$ http://%{HTTP_HOST}%{REQUEST_URI} [NC] 

这是怎么回事? 首先引擎检查HTTPS是否打开。其次,如果第一个条件为真,则引擎使用正则表达式来测试RewriteRule是否匹配。

^ = beginning of URI path 
$ = end of URI path 
.* = any characters, 0 or more times. 

请注意.htaccess在第二步中与整个URI不匹配,这就是我们在第一步中测试HTTPS的原因。

如果这两个条件都满足,那么请求会重定向到HTTP。