大网数据广告活动
网站运营与故障问答

Force HTTP to HTTPS except one page accessed via HTTP

· 52CE 我爱测

I'm trying to redirect a website to HTTPS, but there is one URL that needs to be accessed via HTTP. Currently I just have this in .htaccess : Redirect 301 / https://www.example.com I need to have the following URL available throu…

问题原文

原帖链接 · Esteban Chávez · CC BY-SA 4.0

I'm trying to redirect a website to HTTPS, but there is one URL that needs to be accessed via HTTP. Currently I just have this in .htaccess:

Redirect 301 / https://www.example.com

I need to have the following URL available through HTTP:

http://example.com/asistente/

It is an assistant page separate from the website, that in labor is accessed via QR code.

How can I force HTTPS for everything except that one page listed above?

社区高分解答

原帖链接 · Éric · CC BY-SA 4.0

I agree with Stephen's comment: HTTPS will not break the QR code itself.
There might be some hosting reasons to keep your QR-encoded URL untouched. I guess you may want to avoid any HTTPS issue (old browsers, etc.) with this URL (and its children).

Here are Apache directives which, in an .htaccess file, will redirect all requests to HTTPS, except http://(www.)example.com/asistente and its children URLs.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/asistente($|/)
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2021-03-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。