I have an apache server that sits in front of a JIRA Service Desk instance running on Windows Server 2012.
We have 2 customer portals in JIRA and I need to set up Apache so that each customer portal can be accessed via a different virtual host.
Like this:
- Customer 1 accesses root like
it.mysite.com, or https://it.mysite.com
and gets -- https://it.mysite.com/servicedesk/customer/portal/1 - Customer 1 requests
/servicedesk/customer/portals
and gets
-- https://it.mysite.com/servicedesk/customer/portal/1 any other request at all, like
it.mysite.com/somepage.html
should just get forced to SSLCustomer 2 accesses root like
as.mysite.com, or https://as.mysite.com
and gets -- https://as.mysite.com/servicedesk/customer/portal/2- Customer 2 requests
/servicedesk/customer/portals
and gets
-- https://as.mysite.com/servicedesk/customer/portal/2 - any other request at all, like
as.mysite.com/somepage.html
should just get forced to SSL
This is what I have so far:
<VirtualHost *:80>
RewriteEngine on
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
RewriteRule ^/$ /servicedesk/customer/portal/1/ [R=301]
DocumentRoot "c:/Apache24/htdocs"
#Redirect permanent / https://www.it.mysite.com/ # tried this, it seemed to be ignored
ServerName www.it.mysite.com
ServerAlias it.mysite.com
....
</VirtualHost>
<VirtualHost *:80>
RewriteEngine on
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
RewriteRule ^/$ /servicedesk/customer/portal/2/ [R=301]
DocumentRoot "c:/Apache24/htdocs"
#Redirect permanent / https://www.as.mysite.com/ # tried this, it seemed to be ignored
ServerName www.as.mysite.com
ServerAlias as.mysite.com
....
</VirtualHost>
<VirtualHost *:443>
RewriteEngine on
RewriteRule ^/$ /servicedesk/customer/portal/1 [R=301]
RewriteRule ^/servicedesk/customer/portals$ https://it.mysite.com/servicedesk/customer/portal/1 [R=301]
DocumentRoot "c:/Apache24/htdocs"
ServerName www.it.mysite.com
ServerAlias it.mysite.com
...
</VirtualHost>
<VirtualHost *:443>
RewriteEngine on
RewriteRule ^/$ /servicedesk/customer/portal/2 [R=301]
RewriteRule ^/servicedesk/customer/portals$ https://as.mysite.com/servicedesk/customer/portal/2 [R=301]
DocumentRoot "c:/Apache24/htdocs"
ServerName www.as.mysite.com
ServerAlias as.mysite.com
...
</VirtualHost>
Everything seems to work as expected for it.mysite.com
However, if I go to as.mysite.com, I get:
https://it.mysite.com/servicedesk/customer/portal/2
Https redirect works, the correct portal (2) is shown, but, the domain reverts to it.mysite.com
The same happens for any page I visit.
For example:
- as.mysite.com/somepage.html
gets me https://as.mysite.com/somepage.html
Output for C:\apache24\bin\httpd -S
is:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server www.it.mysite.com (C:/Apache24/conf/httpd.conf:541)
port 80 namevhost www.it.mysite.com (C:/Apache24/conf/httpd.conf:541)
alias it.mysite.com
port 80 namevhost www.as.mysite.com (C:/Apache24/conf/httpd.conf:562)
alias as.mysite.com
*:443 is a NameVirtualHost
default server www.it.mysite.com (C:/Apache24/conf/httpd.conf:596)
port 443 namevhost www.it.mysite.com (C:/Apache24/conf/httpd.conf:596)
alias it.mysite.com
port 443 namevhost www.as.mysite.com (C:/Apache24/conf/httpd.conf:636)
alias as.mysite.com
ServerRoot: "C:/Apache24"
Main DocumentRoot: "C:/Apache24/htdocs"
Main ErrorLog: "C:/Apache24/logs/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/Apache24/logs/" mechanism=default
PidFile: "C:/Apache24/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
C:\Windows\system32>
How can I make it keep the as
subdomain?