【问题标题】:link rewrite in htaccess file for SSL connection在 htaccess 文件中为 SSL 连接重写链接
【发布时间】:2011-08-27 17:35:41
【问题描述】:

我正在使用 php 书来构建电子商务网站。它提供了重写 htaccess 文件的说明,以便站点在某些页面上使用 SSL 连接。这是它给出的代码。

RewriteCond %{HTTPS} off
RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]

问题是我正在使用带有共享 SSL 证书的共享服务器。所以我的网址

https://.example.com/checkout.php

确实需要

https://example.c8.hostexcellence.com/checkout.php

但我不知道如何将.c8.hostexcellence 合并到重写中,以便它通过 SSL 连接

注意,我尝试了以下两种方法,但它们都不起作用。

RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://example.c8.hostexcellence.com/$1 [R=301,L]

RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{example.c8.hostexcellence.com}/$1 [R=301,L]

更新

这是通过 SSL 连接访问它的方式。我需要更改我的 htaccess 文件,以便以这种方式建立链接。

https://titanicraisins.c8.hostexcellence.com/checkout.php?session=72cac503b52a73308af0508fe462090a

这是我当前的 htaccess 文件

AddHandler phpini-cgi .php .htm 动作 phpini-cgi /cgi-bin/php5-custom-ini.cgi

<IfModule mod_rewrite.c>
RewriteEngine on
# For sales:
RewriteRule ^shop/sales/?$ sales.php
# For the primary categories:
RewriteRule ^shop/([A-Za-z\+]+)/?$ shop.php?type=$1
# For specific products:
RewriteRule ^browse/([A-Za-z\+\-]+)/([A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3
# For HTTPS pages:
RewriteCond %{HTTPS} off
RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]

</IfModule>

【问题讨论】:

    标签: php .htaccess ssl


    【解决方案1】:

    去掉%{...},只指定域名

    RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://example.c8.hostexcellence.com/$1 [R=301,L,QSA]
    

    【讨论】:

    • 如果您在我的 OP 底部看到,我实际上尝试过,但没有成功。
    • @Michael: RewriteRule . https://gmail.com --- 这个简单的规则对我有用。所以详细解释一下“不起作用”是什么意思。
    • 由于某种原因,它没有在地址栏中设置 url。它省略了“.c8.hostexcellence.”,因此没有建立安全连接。您可以在 www.titanicraisins.com 上亲自查看 点击咖啡链接,然后选择一种咖啡,然后点击结帐。
    • @Michael:显然你有错误的规则,问题与ssl无关。将您的完整 .htaccess 放入问题中并完成示例网址。
    • @zerkms 我用我的 htaccess 文件更新了我的 OP,还有一个由主机提供商提供给我的链接,显示了应该如何安全链接。
    猜你喜欢
    • 1970-01-01
    • 2017-08-10
    • 2013-11-13
    • 1970-01-01
    • 1970-01-01
    • 2014-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多