我已经尝试了这篇文章,以及其他很多篇文章(1, 2, 3, 4),但所有这些都会给我返回TOO_MANY_REDIRECTS或错误500。因此,这是我的问题:
使用我的当前的.htaccess文件,以下情况发生: https://www.dukescasino.com/ - 完美工作 https://dukescasino.com/ - 重定向到上面的链接,非常好
以下两个选项正常加载,但应该重定向到https版本: http://www.dukescasino.com/ http://dukescasino.com/ 以下是当前的.htaccess文件:
我不认为这是相关的,但如果是的话,这是目前活跃插件的列表:
- Advanced Custom Fields - All In One SEO Pack - Bop Search Box Item Type For Nav Menus - Contact Form 7 - Disable Comments - Google XML Sitemaps - Jetpack by WordPress.com - Search & Filter - Slider WD - TablePress - UpdraftPlus - Backup/Restore - Wordfence Security - WPide - WP Smush - WP Super Cache 测试已执行:
测试 A:
使用我的当前的.htaccess文件,以下情况发生: https://www.dukescasino.com/ - 完美工作 https://dukescasino.com/ - 重定向到上面的链接,非常好
以下两个选项正常加载,但应该重定向到https版本: http://www.dukescasino.com/ http://dukescasino.com/ 以下是当前的.htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我不认为这是相关的,但如果是的话,这是目前活跃插件的列表:
- Advanced Custom Fields - All In One SEO Pack - Bop Search Box Item Type For Nav Menus - Contact Form 7 - Disable Comments - Google XML Sitemaps - Jetpack by WordPress.com - Search & Filter - Slider WD - TablePress - UpdraftPlus - Backup/Restore - Wordfence Security - WPide - WP Smush - WP Super Cache 测试已执行:
测试 A:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Result: ERR_TOO_MANY_REDIRECTS
Test B:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
结果:ERR_TOO_MANY_REDIRECTS
测试 C:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Result: ERR_TOO_MANY_REDIRECTS
Test D:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
结果: ERR_TOO_MANY_REDIRECTS
测试 E:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
结果:302 找到。此外,在试图使用 ErrorDocument 处理请求时遇到了 500 内部服务器错误。
.htaccess
的拼写?你当前的 .htaccess 文件不完整,缺少RewriteEngine On
指令。当你添加规范重定向时,你将其添加到 .htaccess 文件的顶部吗?你说https://example.com
重定向正常,但是在你的配置文件中并没有表明?这是在哪里/如何发生的?知道你实际尝试过什么会很有用 - 而这些却没有起作用。 - MrWhiteHTTPS
被设置(您的结果表明不是这样)。您是否在代理后面?(测试 E 很可能会导致某种形式的“递归” 404?) - MrWhite