http를 https로 Apache 리디렉션

http를 https로 Apache 리디렉션

웹사이트에 대한 리디렉션(http에서 https로)을 활성화하려고 합니다.

내용.htaccess설립됨

RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
ErrorDocument 404 /centreon/index.html

내가 이것을 추가하면 :

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

httpd를 다시 로드하거나 다시 시작한 후 http에서 https로의 리디렉션이 작동하지 않습니다. 어쩌면 규칙 충돌일까요? 죄송하지만 이런 종류의 규칙이 처음입니다.

전역 구성에 대해 나는 이것을 얻었습니다. 10-centreon.conf-> RedirectMatch ^/$ /centreon

기본 사이트는 가상 호스트가 아닙니다

그만큼SSL.conf갖다<VirtualHost _default_:443>

도움을 주셔서 감사합니다.

답변1

짧은 답변이라 죄송합니다. 댓글이어야 하는데 아직 댓글을 달 수 없습니다.

http 가상 호스트로 들어가는 모든 항목을 리디렉션하려고 시도할 수 있으며 포트 80과 포트 443은 두 개의 서로 다른 가상 호스트에서 처리되기 때문에 규칙은 http 트래픽에만 적용됩니다.

답변2

도와주셔서 감사합니다. 드디어 그걸로 끝냈어요10-centron.conf

<VirtualHost *:80>
ServerName supervision
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>

관련 정보