请不要推荐我有超过173个投票的冗长而详尽的主题。它对我不起作用。我还尝试了许多其他(1,2,3,4)。它们都给我TOO_MANY_REDIRECTS或错误500。所以,这是我的问题:
使用我当前的.htaccess,会发生以下情况:
https://www.dukescasino.com/-完美运行
https://dukescasino.com/-重定向到上面的那个很棒
下面的两个选项可以很好地加载,但是应该将其重定向到https版本:
这是当前的.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>
我不认为这是相关的,但是如果是这样,则这是当前活动插件的列表:
- 高级自定义字段
- 多合一SEO包
- 导航菜单的Bop搜索框项目类型
- 联络表格7
- 禁用评论
- Google XML网站地图
- WordPress.com的Jetpack
- 搜索和过滤
- WD滑块
- TablePress
- UpdraftPlus-备份/还原
- 围栏安全
- WPide
- WP Smush
- WP超级缓存
编辑1-执行的测试:
测试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>
结果: ERR_TOO_MANY_REDIRECTS
测试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>
结果: ERR_TOO_MANY_REDIRECTS
测试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 Internal Server Error错误。
.htaccess
了3次(相同方式)?您当前的.htaccess文件不完整,您缺少RewriteEngine On
指令。大概,当您添加规范重定向时,您是将其添加到.htaccess文件的最顶部吗?您指出可以https://example.com
重定向,但是,配置文件中未指出吗?这在哪里/如何发生?知道您实际尝试过的内容很有用-这是行不通的。