I am trying to do the following with Apache:
If I ask for http(s)://domain.local(/) I should be redirected to a completely new domain like this https://www.domain_new.local
If I ask for http://domain.local/gp I should be redirected to https://domain.local/gp
I tried the following, but doesn't seem to work:
<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>