请不要向我推荐 长而非常详细的主题 超过 173 票.它对我不起作用.我也试过很多其他的(1、2, 3、4).他们都给我 TOO_MANY_REDIRECTS 或错误 500.所以,这是我的问题:
Please, don't recommend me the long and very detailed thread with more than 173 upvotes. It didn't work for me. I have also tried many others (1, 2, 3, 4). They all give me TOO_MANY_REDIRECTS or error 500. So, here is my issue:
使用我当前的 .htaccess,会发生以下情况:
With my current .htaccess, this is what happens:
www.dukescasino/ - 完美运行
dukescasino/ - 重定向到上面很棒
dukescasino/ - redirects to the above which is great
下面的两个选项加载正常,但它应该重定向到 https 版本:
The two options below loads fine, but it should be redirecting to the https version:
www.dukescasino/
dukescasino/
这是当前的.htaccess:
Here is the current .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>我不认为它是相关的,但如果是,这里是当前活动插件的列表:
I don't believe it is relevant, but if so, here is the list of current active plugins:
- 高级自定义字段
- 一站式 SEO 包
- 导航菜单的 Bop 搜索框项目类型
- 联系表格 7
- 禁用评论
- Google XML 站点地图
- Jetpack 由 WordPress 提供
- 搜索&过滤器
- 滑块 WD
- TablePress
- UpdraftPlus - 备份/恢复
- Wordfence 安全性
- 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 .* %{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite any request to the wrong domain to use www. RewriteCond %{HTTP_HOST} !^www. RewriteRule .* 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
Result: ERR_TOO_MANY_REDIRECTS
测试 B:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteRule ^.*$ %{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
Result: ERR_TOO_MANY_REDIRECTS
测试 C:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^.*$ %{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
Result: ERR_TOO_MANY_REDIRECTS
测试 D:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} off RewriteRule (.*) %{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
Result: ERR_TOO_MANY_REDIRECTS
测试 E:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ %{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 错误.
Result: 302 found. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
推荐答案问题解决!
最终的.htaccess:
Final .htaccess:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{ENV:HTTPS} !=on RewriteRule ^.*$ %{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>更多推荐
使用 .htaccess 将 HTTP 重定向到 HTTPS
发布评论