apache - 仅在 2 种形式上使用 https,所有其他形式强制返回 http

标签 apache .htaccess redirect ssl https

Google 一直在为欺骗的内容编制索引。 SEO 噩梦...

我有两个需要 SSL 的表单。

/单例

/关节

我希望将其他所有内容重定向回非 ssl (http://)

我已经从这里的论坛中尝试过各种不同的东西,无数次...

How do I enable https only on certain pages with htaccess?

第一部分始终有效,即 https 重定向到 http 但/single &/joint 将重定向到 index.php 或“主页”

提前感谢您的任何建议。

尽量说得更清楚...

将 Jon 的代码添加到 .htaccess 文件中

https .com/其他页面

重定向到 http .com/other-page

但重要的是

https .com/single & .com/joint

都重定向到

http.com/index.php

这是标准 Joomla .htaccess 文件的链接

http://docs.joomla.org/Preconfigured_htaccess

此外,我正在使用重写规则将 www 重定向到非 www

RewriteCond %{HTTP_HOST} !^website.com 重写规则 (.*) http://website.com/ $1 [R=301,L]

最佳答案

将这些规则添加到文档根目录中的 htaccess 文件中:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(single|joint) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} on
RewriteRule !^(single|joint) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

只要将表单作为 GET 请求提交即可。重定向后可能不包含 POST 提交中的请求正文。

关于apache - 仅在 2 种形式上使用 https,所有其他形式强制返回 http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19216255/

相关文章:

redirect - 如何在第三个应用程序中将声音从某些应用程序重定向到某些设备?

HTTP 到 HTTPS 重定向到端口 443 上的负载均衡器后面

apache - 如何使用 htaccess 将访问者重定向到 https ://www. example.com(ssl 以 www 开头)?

javascript - 获取 Facebook 身份验证对话框以重定向到运行我的应用程序的原始浏览器窗口

perl - mod_perl headers_in 不工作

angularjs - 为我的 angularJS Web 应用程序提供静态内容、nodeJS 还是 apache?

Apache 删除请求

.htaccess - 带有编码斜杠的 URL 会出现 404

php - .htaccess 将 403 错误文件重定向到 404 错误文档

apache - XAMPP 或 Apache 中的多个 DocumentRoot