Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8027417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:48:21+00:00 2026-06-04T23:48:21+00:00

At the moment I’m using Apache’s mod_rewrite to redirect all html requests to http(s)://www.domain.com/blah

  • 0

At the moment I’m using Apache’s mod_rewrite to redirect all html requests to http(s)://www.domain.com/blah instead of http(s)://domain.com/blah.

Everything works fine except when I connect to tomcat at domain.com:8080. All I’ve done is naively put the same .htaccess file into my /opt/tomcat-7/webapps/ROOT directory, but it doesn’t seem to work.

I’m actually hoping I’m way off track with what I’ve tried above and there is a way I can always rewrite domain.com:8080 to http://www.domain.com:8080 without having to place a new .htaccess file into every webapp directory, but if not, what am I doing wrong in the above?

I’ve searched all over Google for others having just this problem with tomcat to no avail.

For the record, my .htaccess file is:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Cheers,
Ben.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:48:22+00:00Added an answer on June 4, 2026 at 11:48 pm

    Tomcat doesn’t do anything with .htaccess files: that’s an Apache httpd thing.

    You have a couple of options, here:

    1. Writer a Filter that checks the hostname used to access your webapp and redirects if it doesn’t have the requisite “www.” prefix.
    2. Put two <Host>s in your conf/server.xml file: one with hostname “blah.com” and one with hostname “www.blah.com” where “blah.com” is the default. Then, deploy your webapp only into “www.blah.com” and deploy a simple webapp into “blah.com” that redirects everything to the desired hostname. You can use http://www.tuckey.org/urlrewrite/ to do the real work for you if that helps.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At moment I want to implement picture upload without using any plug-ins. My upload
At the moment I'm using JavaFX only for fun and learning it. What I
At the moment I have about 2000 trades which are priced using excel. I
At the moment I am trying to validate a form using PHP. The problem
at the moment we're using SVN (yeah, I know that's shame :)) and we're
At the moment I am using this to call the TabHost activity to change
Ignoring price for the moment, would using Unity for a 2D game be better
at the moment i am using a while (true) loop to do this. I
Ignore for the moment that not all browsers support LocalStorage. Would it be possible
At the moment I have this to change focus of an element: SendKeys.Send({TAB}) Instead

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.