gpt4 book ai didi

.htaccess - 在 .htaccess 中强制使用 WWW 和 HTTPS (SSL) -- 需要帮助

转载 作者:太空宇宙 更新时间:2023-11-03 15:04:47 28 4
gpt4 key购买 nike

我发现了上千个其他主题寻求帮助,但由于某种原因,他们的解决方案似乎都不起作用。

我几天前刚刚为我的域购买了 SSL,因为我在我的网站上接受信用卡/支票卡,我希望我的客户感到安全。

无论如何,这就是我的 .htaccess 文件目前的样子:

php_flag display_startup_errors off
php_flag display_errors off

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^buy-wow-accounts index.php [NC]
RewriteRule ^sell-wow-accounts sell.php [NC]
RewriteRule ^about-khaccounts about.php [NC]
RewriteRule ^buy-sell-wow-accounts-faq faq.php [NC]
RewriteRule ^khaccounts-feedback feedback.php [NC]
RewriteRule ^payment-plan payment-plan.php [NC]
RewriteRule ^customer-login customer-login.php [NC]
RewriteRule ^customer-center customer-center.php [NC]
RewriteRule ^privacy-policy privacy.php [NC]
RewriteRule ^buy-world-of-warcraft-wow-accounts/page-([0-9]+) listing.php?pageid=$1 [L,NC]
RewriteRule ^buy-world-of-warcraft-wow-accounts listing.php [L,NC]
RewriteRule ^world-of-warcraft-wow-acc/([^/]*)\.html$ account.php?acc=$1 [NC]

我想做的是强制 WWW(如果它不在 URL 中)并确保也强制使用 HTTPS (SSL)。我有大量指向我网站的链接,其中大部分只是“www.khaccounts.net”、“http://khaccounts.net”和“khaccounts.net”之类的链接。

我想确保这些不同的旧链接中的每一个都将被迫拥有 WWW 和 HTTPS。换句话说,我希望人们拥有 URL -“https://www.khaccounts.net”,无论他们使用什么 URL 访问我的网站。

谢谢!

最佳答案

在您的 www 规则添加之后:

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

此外,将您的 www 规则更改为 https://,这样就不会有 2 个重定向。

关于.htaccess - 在 .htaccess 中强制使用 WWW 和 HTTPS (SSL) -- 需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11975519/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com