SSL 连接的 htaccess 文件中的链接重写

发布于 2024-11-08 02:46:46 字数 1707 浏览 0 评论 0原文

我正在使用一本 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洛阳烟雨空心柳 2024-11-15 02:46:46

删除周围的 %{...} 并仅指定域名

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

Remove %{...} around and just specify domain name

RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://example.c8.hostexcellence.com/$1 [R=301,L,QSA]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文