Redirect a subdomain to a different login page

by Duckula   Last Updated September 14, 2018 16:00 PM

I have a domain with a subdomain set up like the following in my vhost.conf file.

<VirtualHost *:80>
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot /opt/mysite/webapps/ROOT/
    ProxyPassMatch / ajp://localhost:8084
</VirtualHost>

<VirtualHost *:80>
    ServerName subdomain.mysite.com 
    ServerAlias www.subdomain.mysite.com
    DocumentRoot /opt/mysite/webapps/ROOT/
    Redirect /index.jsp /index2.jsp
    ProxyPassMatch / ajp://localhost:8084
</VirtualHost>

The main site loads index.jsp but I would like the subdomain to load up a different JSP file (index2.jsp).

I've tried using Redirect but it just goes to index.jsp on the subdomain.



Answers 1


EDIT

The following is wrong due to the presence of ProxyPassMatch.

It's been ages since I last configured an Apache VirtualHost, but I think

DirectoryIndex index2.jsp

is what you're looking for.

So, the complete config would be:

<VirtualHost *:80>
    ServerName subdomain.mysite.com 
    ServerAlias www.subdomain.mysite.com
    DocumentRoot /opt/mysite/webapps/ROOT/

    # Serve index2.jsp as index file
    DirectoryIndex index2.jsp

    ProxyPassMatch / ajp://localhost:8084
</VirtualHost>

EDIT

I didn't look hard enough, looks like the ProxyPassMatch directive overrides a lots of other commands:

As the ProxyPassMatch directive is evaluated as the very beginning of each request:
  -AddType (for MultiView) or DirectoryIndex directives are not usable
  -right management per directory is not available
  -each Alias directive needs another proxy rule

The problem is that your index2.jsp will never be served by Apache as the server's already matched the ProxyPass /, and so it's already been passed to ajp://localhost:8084.

You should then manage serving index.jsp or index2.jsp on ajp://localhost:8084.

Mr Shunz
Mr Shunz
September 14, 2018 15:45 PM

Related Questions



htaccess not working at apache 2.4 virtual host

Updated January 13, 2017 01:00 AM

Can't configure two subdomains apache 2.4

Updated April 28, 2015 22:00 PM

Mass virtual hosting with Apache 2.4

Updated May 22, 2017 03:00 AM