Apacheを使って次のことをしようとしています。
http(s)://domain.local(/) を要求したら、https://www.domain_new.local などの新しいドメインにリダイレクトする必要があります。
私が尋ねるとhttp://domain.local/gp次にリダイレクトする必要があります。https://domain.local/gp
以下を試しましたが、うまくいかないようです。
<VirtualHost *:80>
ServerName domain.local
DocumentRoot "/var/www/html/"
# html directory contains gp directory
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteCond "%{HTTP_HOST}%{REQUEST_URI}" "^domain\.local\/?$"
RewriteRule "^domain\.local\/?$" "https://domain_new.local"
RewriteCond "%{HTTP_HOST}%{REQUEST_URI}" "^domain\.local\/gp(.*)"
RewriteRule "^/?(.*)" "https://%{SERVER_NAME}/$1"
</VirtualHost>
<VirtualHost *:443>
ServerName domain.local
DocumentRoot "/var/www/html/"
SSLEngine on
# html directory contains gp directory
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLCertificateFile /etc/pki/tls/certs/domain.local.crt
SSLCertificateKeyFile /etc/pki/tls/private/domain.local.key
SSLCertificateChainFile /etc/pki/tls/certs/domain.local.ca-bundle
</VirtualHost>
ベストアンサー1
私はテストしていませんが、いくつかの(潜在的な)問題を発見しました。
RewriteCond "%{HTTP_HOST}%{REQUEST_URI}" "^domain\.local\/?$"
以前も問題がある可能性があります\
。一般的に改行するので参加する/
理由はありません。REQUEST_URI
RewriteCond
RewriteRule
RewriteRule "^domain\.local\/?$"
ドメインがそこに属していません。一意にRewriteRule
一致しますREQUEST_URI
。https://domain.local
HTTPS 構成に書き換え規則がありません。