htaccess的,重定向所有请求到https://重定向、htaccess、https

2023-09-02 09:38:28 作者:倁哫常樂

使用的.htaccess,我需要所有的请求重定向从

HTTPS://www.domain

https://开头的域

解决方案

  RewriteEngine叙述上
HTTPS的RewriteCond!上
(。*)重写规则^ $的https://%{SERVER_NAME}%{REQUEST_URI} [R,L,QSA]
 

这应该这样做。

通过 mod_rewrite的手动

交换www.example.com到%{SERVER_NAME}所以它重定向到您尝试访问相同的名字,但通过HTTPS ...

Using .htaccess, I need to redirect all requests from

301重定向怎么做

https://www.domain

to

https://domain

解决方案

RewriteEngine On
RewriteCond HTTPS !on
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L,QSA]

This should do it

via mod_rewrite manual

[EDIT] swapped "www.example.com" to %{SERVER_NAME} so it redirects to same name you've tried to access, but via https...