Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 301 http到https我什么都试过了_.htaccess_Redirect - Fatal编程技术网

.htaccess 301 http到https我什么都试过了

.htaccess 301 http到https我什么都试过了,.htaccess,redirect,.htaccess,Redirect,我在所有支持论坛上尝试了所有答案,尝试了几个小时,很快就开始哭泣。请帮帮我 我只想301所有http到https。如果用户输入http,整个站点都应该使用HTTPS,它应该301到HTTPS。这是我的htaccess文件 现在我只得到循环或服务器错误 在我尝试任何操作之前,这是我的工作访问权限: # BEGIN W3TC Browser Cache <IfModule mod_deflate.c> <IfModule mod_headers.c>

我在所有支持论坛上尝试了所有答案,尝试了几个小时,很快就开始哭泣。请帮帮我

我只想301所有http到https。如果用户输入http,整个站点都应该使用HTTPS,它应该301到HTTPS。这是我的htaccess文件

现在我只得到循环或服务器错误

在我尝试任何操作之前,这是我的工作访问权限:

    # BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -F
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
#开始W3TC浏览器缓存
标头附加变量用户代理env=!不要改变
AddOutputFilterByType DEFLATE text/css text/x-component应用程序/x-javascript应用程序/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon应用程序/json
#扩展放气
AddOutputFilter DEFLATE js css htm html xml
#结束W3TC浏览器缓存
#开始W3TC页缓存核心
重新启动发动机
重写基/
RewriteCond%{HTTP:Accept Encoding}gzip
重写规则。*-[E=W3TC\u ENC:\u gzip]
重写Cond%{HTTP_COOKIE}w3tc_预览[NC]
重写规则。*-[E=W3TC\u预览:\u预览]
重写cond%{REQUEST_METHOD}=邮递
RewriteCond%{QUERY_STRING}=“”
重写cond%{REQUEST_URI}\/$
重写cond%{HTTP_COOKIE}!(注释|作者| wp \-postpass | w3tc |注销| wordpress |登录| wptouch |开关|切换)[NC]
重写条件“%{DOCUMENT_ROOT}/wp content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/{index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}”-F
重写规则。*“/wp content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/{index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}”[L]
#结束W3TC页缓存核心
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress

检查“重写”是否打开不需要多个条件,只需打开“重写引擎”一次即可。将https重定向放在规则的顶部。看看这是否适合你

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

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

   # BEGIN W3TC Page Cache core
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -F
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
    # END W3TC Page Cache core
    # BEGIN WordPress
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

重新启动发动机
重写基/
#重定向到https。
重写cond%{HTTPS}^在…上
重写规则^(.*)https://%{HTTP_HOST}%{REQUEST_URI}[R=301,L]
#开始W3TC页缓存核心
RewriteCond%{HTTP:Accept Encoding}gzip
重写规则。*-[E=W3TC\u ENC:\u gzip]
重写Cond%{HTTP_COOKIE}w3tc_预览[NC]
重写规则。*-[E=W3TC\u预览:\u预览]
重写cond%{REQUEST_METHOD}=邮递
RewriteCond%{QUERY_STRING}=“”
重写cond%{REQUEST_URI}\/$
重写cond%{HTTP_COOKIE}!(注释|作者| wp \-postpass | w3tc |注销| wordpress |登录| wptouch |开关|切换)[NC]
重写条件“%{DOCUMENT_ROOT}/wp content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/{index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}”-F
重写规则。*“/wp content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/{index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}”[L]
#结束W3TC页缓存核心
#开始WordPress
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]

首先,感谢您抽出时间来帮助我。:)如果我没弄错的话,我可以直接说出你给我的密码,然后替换我的旧密码?您省略了这一部分:#结束W3TC页面缓存核心#在RewriteBase/RewriteRule^index\.php$-[L]RewriteCond%{REQUEST_FILENAME}上开始WordPress RewriteEngine-f RewriteCond%{REQUEST_FILENAME}-重写规则/index.php[L]#结束WordPress。当我只是使用你给我的代码时,我得到了相同的错误:ERR_TOO_MANY_重定向使用我给你的代码,并确保清除你的浏览器缓存或尝试其他浏览器,看看它是否工作。将我给你的代码放在
#END W3TC browser cache
下谢谢。我现在已经试着照你说的去做了。还是有同样的错误。我在不同的IP上尝试了不同的浏览器和不同的计算机。这是网站。你能帮我吗?