【发布时间】: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>
【问题讨论】: