SSL 连接的 htaccess 文件中的链接重写
我正在使用一本 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>
I'm using a php book to build a ecommerce site. It gives instructions to rewrite the htaccess file so that the site uses an SSL connection on certain pages. This is the code it gives.
RewriteCond %{HTTPS} off
RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]
The problem is that I'm using a shared server with a shared SSL certificate. So my url
https://.example.com/checkout.php
actually needs to be
https://example.c8.hostexcellence.com/checkout.php
but I can't figure out how to incorporate the .c8.hostexcellence
into the rewrite so that it connects via SSL
Note, I tried the both of the following but they didn't work.
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]
UPDATE
This is how it's supposed to be accessed with an SSL connection. I need to change my htaccess file so the links are established this way.
https://titanicraisins.c8.hostexcellence.com/checkout.php?session=72cac503b52a73308af0508fe462090a
This is my current htaccess file
AddHandler phpini-cgi .php .htm
Action 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除周围的
%{...}
并仅指定域名Remove
%{...}
around and just specify domain name