0

I am using apache 2.2, trying to make rewrite from one url subdomain to another domain, it is working properly on http vhost, but on https not working at all

/etc/apache2/domain1.conf:

 <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            ServerName *.domain1.com

            DocumentRoot /var/www/domain1

            RewriteEngine On

            RewriteCond %{HTTP_HOST} ^sub\.
            RewriteRule (.*) https://sub.domain2 [R=301,L]
    ..........
    ......
    </VirtualHost>

    <VirtualHost xx.xx.xx.xx:443>
            ServerAdmin webmaster@localhost
            ServerName *.domain1.com

            DocumentRoot /var/www/domain1

            RewriteEngine On
            RewriteCond %{HTTPS} on
            RewriteCond %{HTTP_HOST} ^sub\.
            RewriteRule (.*) https://sub.domain2 [R=301,L]
    .......
    </VirtualHost>

Any Help please?

  • Do you have SSL setup on the server? – George Udosen Jul 3 '17 at 17:57
  • I don't see a mod_ssl.c module wrapper around your site! – George Udosen Jul 3 '17 at 18:03
  • Yes, i have it and the ssl is working proberly, i just shortcut the config, as the ssl is not my issue, my issue is rewrite – MohammedSimba Jul 3 '17 at 19:27
  • Wrap it with <IfModule mod_rewrite.c> </IfModule> and lets see, and add RewriteCond %{HTTPS} off – George Udosen Jul 3 '17 at 19:29
  • Didn't work either, http working and redirecting normally, but https not redirecting – MohammedSimba Jul 3 '17 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.