Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

Accessing on different URL, Alias maybe?


I have 1 linux server, with computer name : server1.xyz.com

there it was running 2 java web based application than run on Apache Tomcat. Let's name it : app1, and app2.

by default, we access app1 and app2 by this URL :
http://server1.xyz.com/app1  and

My questions :
Can we access app1 by using URL : app1.xyz.com and app2 by using URL : app2.xyz.com ?

If we can, how to do it?
  • 2
  • 2
  • 2
  • +1
4 Solutions
You can do this using either Alias or ScriptAlias

Alias /app1 app1.xyz.com
Alias /app2 app2.xyz.com
Some of the terms I use are centric to MS's IIS, so you'll have to translate that in to the correct Apache Tomcat terms yourself

You just make sure that the DNS that is authoritative for xyz.com uses 2 CNAMEs (app1 and app2) that both point to the same Host Record of server1.  

Now, no matter if they type:
they still get sent to the same:

Then on the Web Server you define two Sites and define Host Headers for each to identify them

Root Location = the file system directory where app1 resides
Host Header = app1.xyz.com

Root Location = the file system directory where app2 resides
Host Header = app2.xyz.com

Now DNS will resolve to the same IP either way (as it should) and the Web Server will distinguish and choose the correct site by matching the FQDN entered into the user's browser to the Host Header of the correct Site

Yes we can!

First make sure your DNS is properly configured to resolve app1.xys.com to your linux server.

If you want users to enter server1.xyz.com/app1 in their browsers and be redirected to app1.xyz.com, farzanj has the answer.

But if you want the reverse order, you have to perform some transparent URL rewriting in your Apache server to send requests for app1.xys.com to server1.xyz.com/app1 with no need to change your application settings:

RewriteEngine On
RewriteCond %{SERVER_NAME} ^app1.xyz.com$
RewriteRule ^(.*)$ /app1/$1 [PT]

Open in new window

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I like this discussion.  

@aliganjei: I use mod_rewrite all the time, but I think I am not very clear about your comment so kindly explain the bolded phrases that you used.
But if you want the reverse order, you have to perform some transparent URL rewriting in your Apache
I've done exactly what is being asked and I never had to rewrite anything or jump through any "hoops".  I did it just as I described in my post above.   Simple, clean, straight-forward.

As far as I know, using Redirect we can redirect a path to a new URL. So if we have a request for server1.xyz.com/app1 we can easily redirect it to app1.xyz.com as you said.

But I guess may be clients are used to send requests for app1.xyz.com directly and their request should be redirected to server1.xyz.com/app1. In this case I'm not sure if Redirect can be used and seems that we have to use mod_rewrite.

When we are using mod_rewrite, we can specify [R] option to cause modified url to go back to client's browser and make him/her aware of redirection being in place. Or we can choose not to specify this option and let user not be aware of redirection taking place.
softblessAuthor Commented:

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now