简体   繁体   English

WordPress将整个站点重定向到HTTPS,然后将一页的重定向规则添加到HTTP

[英]WordPress redirect full site to HTTPS and then add redirect rule for one page to HTTP

After a long R&D process, I am here with an unresolved issue of WordPress redirection. 经过漫长的研发过程,我在这里遇到了未解决的WordPress重定向问题。 None of the available resources helped me really. 可用资源都没有真正帮助我。

What I need is - 我需要的是-

I have successfully redirected my entire WP site and admin to HTTPS. 我已经成功地将整个WP网站和管理员重定向到HTTPS。

Now, I need one specific page to redirect to HTTP only. 现在,我需要一个特定页面才能仅重定向到HTTP。 Because I will be using iframe on that page to load external sites for preview. 因为我将在该页面上使用iframe加载外部网站进行预览。

My requested url should be like this - 我要求的网址应该是这样-

http://example.com/live-preview/?product_id=(number like 1,2,3 etc) http://example.com/live-preview/?product_id=(数字,例如1,2,3等)

I want the above url(s) to load without HTTPS. 我希望上述网址无需HTTPS即可加载。

My present htaccess file is this - 我现在的htaccess文件是这个-

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R=301,L]

RewriteBase /

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>


# END WordPress

So anything with (/live-preview/) should be on HTTP only. 因此,带有(/ live-preview /)的所有内容都应仅在HTTP上使用。 Please help me how I will be able to do this. 请帮助我,我将如何做到这一点。

Thank you so much. 非常感谢。 -Amit -阿米特

After a long investment of time and many researches, I manage to fix this issue with my code. 经过长时间的投入和大量研究,我设法用我的代码解决了这个问题。 I am sharing this for public interest. 我出于公共利益而分享此内容。

This is the working htaccess code - 这是有效的htaccess代码-

RewriteCond %{HTTPS} !on
RewriteCond %{QUERY_STRING} !^product_id=(.*)$
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]


RewriteCond %{HTTPS} on
RewriteCond %{QUERY_STRING} ^product_id=(.*)$
RewriteRule ^(.*)$ http://%{SERVER_NAME}/$1 [R=301,L]

So I have to use {QUERY_STRING} and use 2 conditions with 301 permanent redirection. 因此,我必须使用{QUERY_STRING}并使用2个条件和301个永久重定向。

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

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