简体   繁体   English

强制URL为http而不是https

[英]Force URL to be http and not https

I'm running a WordPress / WooCommerce site. 我正在运行一个WordPress / WooCommerce网站。 Most URLs have no problem with being SSL / https, now with one plug-in I found it causes a problem on HTTPS so I want the URL for this plugin to be HTTP instead of HTTPS. 大多数URL都没有SSL / https的问题,现在有一个插件,我发现它导致HTTPS出现问题所以我希望这个插件的URL是HTTP而不是HTTPS。

The URL looks like this: URL如下所示:

https://www.example.com/ontwerp-zelf/?product_id=1432&cart_id=d866d4bd644dd570146434238434f345

I want to rewrite it so that when it finds ontwerp-zelf in the string it automatically rewrites to HTTP. 我想重写它,以便当它在字符串中找到ontwerp-zelf时会自动重写为HTTP。

Any suggestions please? 有什么建议吗?

To redirect from HTTPS back to HTTP for URLs that contain the string "ontwerp-zelf" (at the start), try the following (before your existing WP directives but after your existing canonical redirects): 要从HTTPS重定向到包含字符串“ontwerp-zelf”的URL(在开始时),请尝试以下(在现有WP指令之前但现有规范重定向之后):

RewriteCond %{HTTPS} on
RewriteRule ^(ontwerp-zelf.*) http://%{HTTP_HOST}/$1 [R=302,L]

Note that the order of directives in .htaccess is important. 请注意.htaccess中指令的顺序很重要。

This is currently a 302 (temporary) redirect. 这是一个302(临时)重定向。 Change this to a 301 (permanent) when you are sure it's working OK. 当您确定它正常工作时,将其更改为301(永久)。 301s are cached hard by the browser so can make testing problematic. 301s被浏览器缓存,因此可能会使测试出现问题。

However, you need to also exclude these URLs from being redirected in your existing canonical HTTP to HTTPS redirect, as otherwise you will end up with a redirect loop. 但是,您还需要排除这些URL在现有规范HTTP中重定向到HTTPS重定向,否则您将最终得到重定向循环。 So, if you currently have something like: 所以,如果你现在有类似的东西:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

Then you will need to insert an additional condition to prevent it from being redirected to HTTPS in the first place. 然后,您需要插入一个附加条件,以防止它首先被重定向到HTTPS。

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/ontwerp-zelf
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

The CondPattern !^/ontwerp-zelf states that the REQUEST_URI must not start with /ontwerp-zelf . CondPattern !^/ontwerp-zelf声明REQUEST_URI不能以/ontwerp-zelf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM