Apache htaccess重定向不';例如:我不能在example.com上工作https://example.com

Apache htaccess重定向不';例如:我不能在example.com上工作https://example.com,apache,.htaccess,ssl,redirect,Apache,.htaccess,Ssl,Redirect,我的重定向目标如下: http://-->https:// www.example.com-->example.com example.com-->https://example.com 我当前正在使用以下命令进行.htaccess重定向: RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [NE,R=301] RewriteCond %{HTTPS} !=on RewriteR

我的重定向目标如下:

  • http://-->https://
  • www.example.com-->
    example.com
  • example.com-->
    https://example.com
我当前正在使用以下命令进行.htaccess重定向:

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,R=301]

RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
这些规则适用于除以下请求之外的所有请求: example.com-->
example.com%7b请求uri%7D
NOT
https://example.com


在做了一些研究之后,问题可能是SSL是如何设置的?或者可能是主机服务器配置文件中的某些代码?

尝试使用此规则从非https重定向到https:

RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]