Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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 htaccess重写以要求www、https和ip_Apache_.htaccess_Mod Rewrite_Rewrite_Forwarding - Fatal编程技术网

Apache htaccess重写以要求www、https和ip

Apache htaccess重写以要求www、https和ip,apache,.htaccess,mod-rewrite,rewrite,forwarding,Apache,.htaccess,Mod Rewrite,Rewrite,Forwarding,我正在试图找出如何编写.htaccess,以便所有URL: 1) 使用https 2) 从转到 3) 从服务器IP转发到域 我试过: RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} ^111\.11\.111\.111 RewriteRule ^ https://www.{HTTP_HOST}/%{REQUES

我正在试图找出如何编写.htaccess,以便所有URL: 1) 使用https 2) 从转到 3) 从服务器IP转发到域

我试过:

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^111\.11\.111\.111
RewriteRule ^ https://www.{HTTP_HOST}/%{REQUEST_URI} [L,R=301]
但这不起作用。IP是实际的服务器IP


我做错了什么?

您可以在一条规则中完成这一切:

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301,NE]