在htaccess中将http重定向到https的问题

时间:2017-10-18 17:57:09

标签: wordpress .htaccess ssl redirect https

我正在努力将WordPress网站转换为https,而我在htaccess中进行自动重定向时遇到问题。我可以让主页重定向,但没有别的。我正在使用:

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://selfreliantschool.com/$1 [R=301,L]

我也尝试过:

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://selfreliantschool.com/$1 [R=301,L]

但是除了主页之外,它们都不起作用。这是主页:http://selfreliantschool.com,这是另一页:http://selfreliantschool.com/christmas-gift-bootcamp/。第一件作品,第二部件没有。有什么建议吗?

4 个答案:

答案 0 :(得分:1)

试试这个:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

答案 1 :(得分:1)

检查您的网址 - >设置。如果这不起作用,请查看您的wp-config文件以查看主页和siteurl是否被覆盖。

Traceback (most recent call last):
    File "/home/jwelborn/Documents/projects/Bingo/bingo/cards/tests/test_forms.py", line 218, in test_formset_accepts_valid_data
        self.assertTrue(formset.is_valid())
    File "/home/jwelborn/Documents/projects/Bingo/bingoenv/lib/python3.6/site-packages/django/forms/formsets.py", line 321, in is_valid
        self.errors
    File "/home/jwelborn/Documents/projects/Bingo/bingoenv/lib/python3.6/site-packages/django/forms/formsets.py", line 295, in errors
        self.full_clean()
    File "/home/jwelborn/Documents/projects/Bingo/bingoenv/lib/python3.6/site-packages/django/forms/formsets.py", line 343, in full_clean
        for i in range(0, self.total_form_count()):
    File "/home/jwelborn/Documents/projects/Bingo/bingoenv/lib/python3.6/site-packages/django/forms/formsets.py", line 116, in total_form_count
        return min(self.management_form.cleaned_data[TOTAL_FORM_COUNT], self.absolute_max)
    File "/home/jwelborn/Documents/projects/Bingo/bingoenv/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
    File "/home/jwelborn/Documents/projects/Bingo/bingoenv/lib/python3.6/site-packages/django/forms/formsets.py", line 98, in management_form
        code='missing_management_form',
    django.core.exceptions.ValidationError: ['ManagementForm data is missing or has been tampered with']

答案 2 :(得分:1)

放弃htaccess路线并安装了一个修复重定向问题的插件(Really Simple SSL)。

答案 3 :(得分:0)

我会下载你的SQL文件,然后查找并替换http到https

您可以在代码编辑器(如Notepad ++或Sublime)中执行此操作,您可以使用快捷键Ctrl + H

然后删除原始SQL表并插入编辑过的表。

但请先备份 - 其他人可能会有不同的解决方案,只有在您有信心的情况下才能执行以上操作