2017-09-11 17 views
0

私はLinuxとApacheで遊んで始めたばかりです。Apache HTTPS URLリライト

私は正常に動作し、この書き換えルールを持っている:

RewriteEngine on 
RedirectMatch ^/$ /myserver/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /myserver/ [R] 

は、どのように私はこれらの同じルールを適用httpsにリダイレクトすることができますか?

ありがとうございます!

答えて

0

On the Apache wiki:

RewriteCond %{HTTPS} !=on 
# This checks to make sure the connection is not already HTTPS 

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 
# This rule will redirect users from their original location, to the same location but using HTTPS. 
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/ 
# The leading slash is made optional so that this will work either in httpd.conf 
# or .htaccess context 

私が正しくあなたの質問を理解していれば、あなたはあなたの特定の例でこれを実装することができます。

セキュリティで保護されていないVirtualHostの内部で、セキュアなVirtualHostにリダイレクトすることをお勧めします。