简体   繁体   English

301重定向在浏览器中有效,但状态为200

[英]301 redirect works in browser but gives status 200

I added an ssl cert and want to have https only. 我添加了ssl证书,并且只想拥有https。 In browser http requests are forwarded to https, but curl -I http://www.domain.com returns HTTP/1.1 200 OK. 在浏览器中,http请求被转发到https,但是curl -I http://www.domain.com返回HTTP / 1.1 200 OK。 Afaik googlebot will see status 200, too, but has to see it's moved permanently. Afaik googlebot也将看到状态200,但必须看到它已永久移动。 Is .htaccess wrong? .htaccess错误吗?

WHM 60 (B35), CentOS 7.3, Wordpress WHM 60(B35),CentOS 7.3,Wordpress

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Header set Strict-Transport-Security "max-age=31536000; preload; includeSubDomains" env=HTTPS

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
</IfModule>

I figured out code below returns domain, folders and files with 301 我发现下面的代码用301返回域,文件夹和文件

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
</IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM