0

Here's what I'm trying to achieve :

  1. redirection to 2 different application hosted for 2 different domain
  2. redirect to https://
  3. Not www-domain
  4. Make sure trailing slash gets appended in-case user misses out.

Please note : It's a shared instance - so there's another application configured already.

My Current solution configuration :

# VirtualHost Listening on Port 80
123.123.1.1:80

# Original Configuration for Existing Application
<VirtualHost *>
ServerName 123.123.1.1:80
# Additional cluster configuration using Proxy ( mod_proxy ) & LoadBalancer
</VirtualHost>

<VirtualHost *>
ServerName domain1.com

Redirect / https://domain1.com/app1/$1
</VirtualHost>

<VirtualHost *>
ServerName domain2.com

Redirect / https://domain2.com/app2/$1
</VirtualHost>

Alternatives I have tried are :

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://domain1.com/app1/$1


RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://domain2.com/app2/$1

Can someone please point out what additional configuration shall i do ? What is my mistake ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Pranav
  • 167
  • 1
  • 3
  • 16

1 Answers1

0

Try using a condition to look for the domain then redirect based on the incoming domain being requested.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com [NC]
RewriteRule (.*)$ https://domain1.com/app1/$1/ [R=301,L]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com [NC]
RewriteRule (.*)$ https://domain2.com/app2/$1/ [R=301,L]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95
  • Unfortunately the solution did not work for me. It is going into infinite redirects. I have links like following in the application (https://m.domain.com/app1/login.html#pagename) and (https://m.domain.com/app1/test.html?id=1&id=2) – Pranav Sep 04 '15 at 18:43