【问题标题】:htaccess redirect https to http except specific pageshtaccess 将 https 重定向到 http,特定页面除外
【发布时间】:2015-10-27 14:40:56
【问题描述】:

我想将几乎所有页面的 https 重定向到 http,结帐和帐户除外。

这不是将 https 重定向到 http 的方法,我需要一些页面例外,需要在 https 上运行。

如何在我的 htaccess 中定义它?

我试过这个,但不起作用:

Options +FollowSymLinks
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/
RewriteCond %{REQUEST_URI} !^/customer/account/
RewriteCond %{REQUEST_URI} !^/checkout/
RewriteCond %{REQUEST_URI} !^/wishlist/
RewriteCond %{REQUEST_URI} !^/ebizautoresponder/
RewriteCond %{REQUEST_URI} !^/index.php/admin/dashboard/index/key/
#RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

我使用这个 Magento 设置(我删除了整个 URL):

【问题讨论】:

  • 鉴于大部分内容已被注释掉,尤其是重写,它不会做任何事情......
  • @MarcB 对不起,应该是这个。

标签: apache .htaccess magento redirect


【解决方案1】:

试试这条规则作为你的第一条规则

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !\s/+(customer/account|checkout|wishlist|ebizautoresponder|index\.php/admin/dashboard/index/key) [NC]
RewriteRule !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$ http://%{HTTP_HOST}%{REQUEST_URI} [NE,NC,L,R=301]

【讨论】:

  • 谢谢!我试过你的代码,它确实重定向到https上的结帐。但它只会分解其他代码,如 css 和其他内容。这怎么可能?
  • 谢谢,差不多好了!除了图标的字体显示不好。以 Font Awesome 为例。
  • icons 的完整 GET 请求是什么?是否以.ico 结尾?
  • 是的,但是还有更多的东西被破坏了。那么没有其他或更好的方法来解决这个问题吗?因为它默认在 https 上运行良好,但所有其他页面都应该重定向到 http。
  • 除非您提供具体信息 more things that are broken 不会有太大帮助。您甚至没有提供完整的 .htaccess 有问题。您还需要提供不起作用的 URL。
猜你喜欢
  • 2016-09-16
  • 2013-10-18
  • 2012-11-07
  • 2012-10-08
  • 1970-01-01
  • 2019-12-14
  • 1970-01-01
  • 2012-03-26
  • 1970-01-01
相关资源
最近更新 更多