Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Apache 正在将非WWW和HTTP重定向到HTTPS://WWW。。。一步到位?_Apache_.htaccess_Redirect_Https - Fatal编程技术网

Apache 正在将非WWW和HTTP重定向到HTTPS://WWW。。。一步到位?

Apache 正在将非WWW和HTTP重定向到HTTPS://WWW。。。一步到位?,apache,.htaccess,redirect,https,Apache,.htaccess,Redirect,Https,假设我的站点在url中同时包含HTTPS和WWW,而不是http mysite.com 按照我设置.htaccess的方式,如果有人进入http mysite.com,路径如下:重定向到https,然后重定向到www.htaccess 我的.htaccess: AddDefaultCharset UTF-8 Options +FollowSymlinks ServerSignature Off Options -Indexes <IfModule mod_rewrite.c> Rew

假设我的站点在url中同时包含HTTPS和WWW,而不是http mysite.com

按照我设置.htaccess的方式,如果有人进入http mysite.com,路径如下:重定向到https,然后重定向到www.htaccess

我的.htaccess:

AddDefaultCharset UTF-8
Options +FollowSymlinks
ServerSignature Off
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
rewritecond %{http_host} ^www.mysite.com [nc]
rewriterule ^(.*) http: (cant write url here) mysite.com/$1 [r=301,nc,l]
</IfModule>
AddDefaultCharset UTF-8
选项+FollowSymlinks
服务器签名关闭
选项-索引
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
重写cond%{http_host}^www.mysite.com[nc]
重写规则^(.*)http:(无法在此处写入url)mysite.com/$1[r=301,nc,l]
注意:我还没有实现https,我只是想知道如何实现它

我知道还有另外一条线索,但我真的不知道该怎么做,因为我的htaccess看起来不一样


我能把它分成一个步骤吗?我担心在谷歌眼中,数个301s会降低链接的价值

您可以使用此规则重定向到
https://www
在单个http请求中

RewriteEngine on

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$
RewriteRule .* https://www.%1%{REQUEST_URI} [L,NE,R=301]