Apache htaccess重写以要求www、https和ip
我正在试图找出如何编写.htaccess,以便所有URL: 1) 使用https 2) 从转到 3) 从服务器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
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]