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

时间:2017-01-24 13:53:29

标签: wordpress apache .htaccess redirect

我添加了一个ssl证书,并且只想使用https。在浏览器中,http请求被转发到https,但是curl -I http://www.domain.com返回HTTP / 1.1 200 OK。 Afaik googlebot也将看到状态200,但必须看到它永久移动。 .htaccess错了吗?

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>

1 个答案:

答案 0 :(得分:0)

我发现下面的代码返回带有301

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