2

Can we configure apache in such a way that we can point 2 different applications to the same domain name with the last part of the url changing accordingly.

example:

APP 1 - test.example.com/app1
APP 2 - test.example.com/app2

test.example.com/app1 - should point to different DocumentRoot and Directory test.example.com/app2 - should point to different DocumentRoot and Directory

2

You need to use "Apache Module mod_alias" for this purpose. It is by default present in /etc/httpd/modules/ directory.

To configure your alias using this module please take help from this link provided by Apache.

Eg. In my office we are using one apache server for multiple sites.

[root@web ~]# cd /etc/httpd/conf.d/

To see first 5 lines I am using head command on three differnt configuration files.
1. nagvis.conf

[root@web conf.d]# head -n 5 nagvis.conf
# NagVis Apache2 sample configuration file
#
# #############################################################################

Alias /nagvis "/usr/local/nagvis/share"  

2. pnp4nagios.conf

[root@web conf.d]# head -n 5 pnp4nagios.conf
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER

Alias /pnp4nagios "/usr/local/pnp4nagios/share"

<Directory "/usr/local/pnp4nagios/share">  

3. sarg.conf

[root@web conf.d]# head -n 5 sarg.conf 
Alias /sarg /var/www/sarg

<Directory /var/www/sarg>
    DirectoryIndex index.html
    Order deny,allow  

And after this when I want to open any link I just enter the Alias name following to the domain. Like: http://web.cmc.com/sarg OR http://web.cmc.com/pnp4nagios

If you are using phusion passenger this link may be helpful.

  • So, in the same virtual host I should create a alias ? – Karthik K Jul 22 '15 at 8:55
  • I have edited my answer for your clarification – Tejas Jul 22 '15 at 9:24
  • Should I make any changes to the Directory index settings? – Karthik K Jul 22 '15 at 12:27
  • no you only need to add Alias </lastPart> </full/domain_path> line, before (not inside) <Directory /full/domain/path/> – Tejas Jul 23 '15 at 4:02
  • I tried the above configuration, but did not work. We are using a ruby on rails stack with apache and phusion passenger configuration, if that helps – Karthik K Jul 24 '15 at 12:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.