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文件要做的是重定向主域,而不是(100+;)子域_.htaccess_Redirect - Fatal编程技术网

.htaccess文件要做的是重定向主域,而不是(100+;)子域

.htaccess文件要做的是重定向主域,而不是(100+;)子域,.htaccess,redirect,.htaccess,Redirect,谁能给我一些关于.htaccess重写规则的建议 我现在在我的域上激活了https(SSL证书),但我没有购买多域证书。 因此,我需要.htaccess文件做的是重定向主域,而不是(100+)子域,这意味着: http://www.example.com -> https://www.example.com http://example.com -> https://www.example.com http://subdomain.example.com -> http://w

谁能给我一些关于.htaccess重写规则的建议

我现在在我的域上激活了https(SSL证书),但我没有购买多域证书。 因此,我需要.htaccess文件做的是重定向主域,而不是(100+)子域,这意味着:

http://www.example.com -> https://www.example.com
http://example.com -> https://www.example.com
http://subdomain.example.com -> http://www.example.com
因为我有100多个子域名,它需要是通用的

现在,我有了这个.htaccess代码

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
但这会将所有内容重定向到HTTPS,并且不会排除现在发出安全警告的子域。 所以,我可能需要添加一个额外的条件,只包括root和www

谁能给我一些建议


Jo

在以下条件下尝试

RewriteEngine On
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

在以下条件下尝试

RewriteEngine On
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]