0

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

几天前我刚刚为我的域购买了 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 访问我的网站。

谢谢!

4

4 回答 4

0

在您的 www 规则之后添加:

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

另外,将您的 www 规则更改https://为没有 2 个重定向。

于 2012-08-15T19:10:05.317 回答
0

Looks like you're rewriting all of your urls to the root. Why don't you try:

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}/$1 [R=301,L]
于 2012-08-15T19:11:47.670 回答
0

Try replacing these lines :

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

With this :

RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.khaccounts\.net$ [NC]
RewriteRule ^(.*)$ https://www.khaccounts.net/$1 [R=301,L,QSA]
于 2012-08-15T19:12:00.913 回答
0

这可以在 khaccounts.net 被点击时显示正确的 URL,但仍会引发重定向循环。

RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.khaccounts.net/$1 [R=301,L,QSA]
于 2012-08-15T21:50:02.493 回答