Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resolving website name correctly in Tomcat

 
Deep Nair
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My httpd file in Apache as proxy looks like below:


In Tomcat, my server.xml looks like below:


What's happening is that, in the browser, when I type www.mywebsitename.com, it shows only the Apache Welcome page but when I type www.mywebsitename.com/SYL, it shows the website welcome page.

What I want is that the www.mywebsitename.com should resolve to www.mywebsitename.com/SYL, so that the general user need not type /SYL in url. Please suggest.

Thanks,
Deepna
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Place an index.php file in your Apache's htdocs folder with the following content:
This way, when someone goes to the root, this index.php will be returned which tells the browser to go to SYL instead.
Note: you must have the PHP plugin enabled in Apache, and you may have to remove the existing index.html file.
 
Deep Nair
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob for the details, I'm using centos linux server, so i dont see the folder htdocs. How can i set it up in Centos ? Also im not using PHP, but JSP, is there a JSP plugin similar to PHP that needs to be enabled ?
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you running JSP directly in Apache, or in Tomcat? The PHP part should go in Apache, not Tomcat. It is a plugin that would need to be configured. Alternatively you can do it in HTML as well:
As for the location, you may also want to try /var/www/html. If that also does not exist, check httpd.conf and look for the value of the DocumentRoot directive.
 
Deep Nair
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the details, tried with the html option but could not make it work. In the httpd conf i can see the doc root set as var/www/html so created index.html and placed in html dir and restarted apache but didnt see any changes....not sure why its not working ...
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18226
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to forward the entire site over using this pair of statements:


However, the key word there is entire. That would force ALL URL requests for that host to be proxied to the SYL webapp in Tomcat. Which is OK, if that's the only webapp you intend to serve up. A variation of that idea would be to define the Proxy for an alternate virtual host, which would have a different domain name in the URL.

Mixing Tomcat and non-Tomcat requests on the same host and trying to share the same domain hostname can be tricky and usually involves extensive use of the mod_rewrite module. That's because you need clear rules as to what subsections of the URL would go where.
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deep Nair wrote:Thanks for the details, tried with the html option but could not make it work. In the httpd conf i can see the doc root set as var/www/html so created index.html and placed in html dir and restarted apache but didnt see any changes....not sure why its not working ...

Is there perhaps also an index.php in the same folder? If that's the case this is probably seen as the default document, and served instead of the index.html. What happens if you go to www.mywebsitename.com/index.html?
 
Deep Nair
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there perhaps also an index.php in the same folder?

No there is no index.php in the same folder.

Also one more thing i have noticed is in IE if i type www.mywebsitename.com it resolves to the www.mywebsitename.com/SYL so its working in IE, but in Firefox its not working, in Firefox its still shows the Apache home page. So the index.html that you gave me earlier, does that need to be changed for Firefox compatibility ?

What happens if you go to www.mywebsitename.com/index.html?

I tried this in Firefox and its resolving to www.mywebsitename.com/SYL properly.... so not sure where the issue is.

Thanks,
deepna
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps Firefox still has an old version in its cache. Clear the cache (Options, Advanced, Network tab, Clear Now), then try again.
 
Deep Nair
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob for your inputs !! yes clearing cache solved the issue...

Thanks,
**
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic