会社ごとに動的サブドメインが必要な Web アプリケーションがあります。また、このサイトには SSL もあります。Ubuntu VPS で apache を使用しています。私がしたことは、以下のような仮想ホスト設定を行ったことです
<VirtualHost *:80>
ServerName domain.com
ServerAlias *.domain.com
Redirect permanent / https://domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName domain.com
ServerAlias *.domain.com
..........
.................
</VirtualHost>
トラフィックを SSL に転送しても問題ありません。
だから私が今する必要があるのは、Web ルートに "/app" フォルダーがあることです。すべてのサブドメインがその特定のフォルダーに直接移動し、アドレスバーに同じ URL が表示されるようにします。
PHPでhttp_proxyモジュールを有効にして、これを.htaccessにしました
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/app/$1 [P,NC,QSA]
「 https://test.domain.com 」にアクセスすると、「 https://domain.com/app/index.php 」にリダイレクトされます。htaccess リダイレクトが「 http://domain.com/app/index.php」に発生すると、仮想ホスト構成が非 SSL 要求を認識し、SSL を使用して同じアドレスに要求をリダイレクトするため、なぜそれが起こっているのかを知っています。だから私はこれに.htaccessを変更しました
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ https://domain.com/app/$1 [P,NC,QSA]
書き換えルールに「https」を入れました。「 https://test.domain.com 」に再度アクセスすると、このエラーが発生しました。
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at webmaster@localhost to
inform them of the time this error occurred, and the actions you
performed just before this error.
More information about this error may be available in the server error
log.
Apache/2.4.7 (Ubuntu) Server at kjdcndkj.domain.com Port 443
最後に私が欲しいのは
1) redirect any Non-SSL trafic to SSL
2) any *.domain.com to /app folder
誰かがこれについて私を助けることができますか
ありがとうございました。