.htaccess Htaccess-从http重写为https,从www重写为非www

.htaccess Htaccess-从http重写为https,从www重写为非www,.htaccess,redirect,url-rewriting,rewrite,url-redirection,.htaccess,Redirect,Url Rewriting,Rewrite,Url Redirection,我正在尝试将http格式重写为https格式,将www格式重写为非www URL格式 基本上,如果有人转到,他们需要重定向到错误URL的所有其他实例(,等等) 我尝试将建议拼凑在一起: RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{HTTP_HOST} ^www\.garrysun\.com [NC]

我正在尝试将http格式重写为https格式,将www格式重写为非www URL格式

基本上,如果有人转到,他们需要重定向到错误URL的所有其他实例(,等等)

我尝试将建议拼凑在一起:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^www\.garrysun\.com [NC]
RewriteRule ^(.*)$ https://garrysun.com/$1 [L,R=301]
但是当我在重定向检查器中检查URL时,我会得到错误。。。工作正常并转到,但得到以下结果:

选中链接: 重定向类型:301已永久移动 重定向到:

如何更正我的重写代码

另外,我正在使用OpenCart 1.5.4,在新的东西上面我还有以下重写代码(不知道它是否会影响任何东西):


对于该要求,您可以使用此单一规则:

RewriteEngine On
RewriteBase /

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

# rest of your rules will appear below
RewriteEngine On
RewriteBase /

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

# rest of your rules will appear below