• Post Reply Bookmark Topic Watch Topic
  • New Topic

host header: redirect to one domain from many  RSS feed

 
Swapan Mazumdar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have quite few domains for a single website. How can I identify the host header and always redirect to a single website. Let me explain with an example.
  • www.xyz.com
  • www.xyz.net
  • www.xyz.org
  • No matter what web address the user types from among the mentioned domains, the host header should be changed to www.xyz.com and the webpages should be served from the application that is bound to www.xyz.com

    How should I be able to handle this requirement using Servlet Filter and/or creating Virtual Host in tomcat?

    Please share your views and ideas.

    thanks & b regards,
    Swapan
     
    William Brogden
    Author and all-around good cowpoke
    Rancher
    Posts: 13078
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Virtual hosts would not work because the header would not be changed.
    If you want the header changed, that sounds like a job for a HttpServletRequestWrapper managed by a filter.
    Why do you want the header to be changed - wont that just confuse people?
    Why not examine the host in the request and do a redirect to the host name you want to use?
    Bill
     
    Swapan Mazumdar
    Ranch Hand
    Posts: 83
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by William Brogden:
    ...Why do you want the header to be changed - wont that just confuse people?
    Why not examine the host in the request and do a redirect to the host name you want to use?
    Bill

    I am so much glad that you have attended to my post. Actually we are using one product for online booking engine wherein the default home page url needs to be configured for many reason. And secondly only one domain is registered for ssl certificate.

    I don't want to create separate applications for all the domains and redirect from the default page.

    Could you pl. advise if creating virtual hosts for all others and writing filter for the main web app. will be a good choice.

    thanks n b regards,
    Swapan
    [ August 30, 2005: Message edited by: Swapan Mazumdar ]
     
    William Brogden
    Author and all-around good cowpoke
    Rancher
    Posts: 13078
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Could you pl. advise if creating virtual hosts for all others and writing filter for the main help will be a good choice.

    If I understand you correctly, you will be processing requests directed to a variety of domains and you want them to all go to the same web application.

    If all of your various "hosts" are mapped to the same IP address, there is no need to configure the server to send requests to different applications which is what a virtual host mapping is intended for.

    The default home page servlet can look at the host specified and generate a custom response accordingly. See the methods in ServletRequest.

    Unfortunately, I don't know how this would affect the SSI certificate use - won't the customer be asked to accept a certificate from the single domain, rather than the domain he connected to?

    Bill
     
    Swapan Mazumdar
    Ranch Hand
    Posts: 83
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    ...If all of your various "hosts" are mapped to the same IP address, there is no need to configure the server to send requests to different applications which is what a virtual host mapping is intended for.

    Thank you so much for the suggestion. I have implemented as advised.
    ...The default home page servlet can look at the host specified and generate a custom response accordingly. See the methods in ServletRequest.

    Why do you think implementing the above requirement will be best achieved through default servlet. I have chosen to implement using Filter. I haven't implemented web app's default servlet as yet. What could be possible implications of not going on default servlet's way?

    I appreciate your comments.

    thanks n b rgrds,
    Swapan
     
    William Brogden
    Author and all-around good cowpoke
    Rancher
    Posts: 13078
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Using a Filter is perfectly valid and more flexible than a default servlet. I only suggested the default servlet as one possible approach.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!