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

  • SEARCH
  • Home
  • 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 67619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:17:18+00:00 2026-05-10T19:17:18+00:00

I’ve got a tomcat 6 web app running with Apache httpd as the front

  • 0

I’ve got a tomcat 6 web app running with Apache httpd as the front end. I’m using mod_proxy and mod_proxy_ajp to forward the requests to tomcat. My server is running Ubuntu. Now I’m trying to use mod_rewrite to remove the leading www, so that my canonical website URL is http://example.com rather than http://www.example.com

I’ve read a number of tutorials on using mod_rewrite, but I can’t get any rewriting to work. I’ve tried putting the rewrite rule in an .htaccess file (after modifying my /etc/apache/sites-available/default file to set AllowOverride all). I’ve tried putting the rewrite rule in apache2.conf, httpd.conf, and rewrite.conf. I’ve tried all of these with rewrite logging turned on. The log file gets created, but Apache has written nothing to it. I thought maybe mod_proxy was somehow preventing the rewrite rules from being used, so I tried disabling that as well…and I still get no rewrite, and nothing to the log.

At this point I have absolutely no idea what to try next. How do I go about troubleshooting why Apache isn’t using my rewrite rules?

For reference, here are my rewrite directives:

<IfModule mod_rewrite.c>      RewriteEngine on     RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]     RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]     RewriteLog "/var/log/apache2/rewrite.log"     RewriteLogLevel 3  </IfModule> 

the responses below are helpful to my particular case, but probably not as helpful to the community-at-large as answers about how you troubleshoot Apache directives in general. For example, is there a way to enable logging to the point where it would tell me which directives are being applied in which order as the request comes in?

Edit 2: I’ve gotten things to work now. My virtual hosts weren’t quite set up right, and I also didn’t quite have the rewrite regex right. Here is the final rewrite directives I got to work:

<IfModule mod_rewrite.c>         RewriteEngine On         RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]         RewriteRule ^(.*)$ http://example.com$1 [L,R=301] </IfModule> 
  • 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. 2026-05-10T19:17:18+00:00Added an answer on May 10, 2026 at 7:17 pm

    Trying to answer your question: To debug Apache operation you can adjust the LogLevel to a lower level (maybe debug). But even if you put debug if you disable the Log for the module in question you dont get any messages from it. For instance, the default [RequestLogLevel][2] is 0, e.g., the module dont write any messages. I see you setted it to 3 but like RoBorg said change it to 9 that maybe is too low for your case.

    Trying to sove your problem: Try to change the way you rewrite the hostname using the inverse form – look if the hostname is what you want and, if not, change it to the hostname you want. Like stated in the URL Rewriting Guide – Apache HTTP Server at the Apache Site:

    Canonical Hostnames

    Description: The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of http://www.example.com instead of example.com, you might use a variant of the following recipe. Solution:

    # To force the use of  RewriteEngine On RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC] RewriteCond %{HTTP_HOST}   !^$ RewriteRule ^/(.*)         http://www.example.com/$1 [L,R] 

    In their example, they change from example.com to www.example.com but you got the idea. Just adjust it for your case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 94k
  • Answers 94k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Levinshtein is relevant, but will not give you a value… May 11, 2026 at 6:46 pm
  • Editorial Team
    Editorial Team added an answer If you want to get started with GUI design in… May 11, 2026 at 6:46 pm
  • Editorial Team
    Editorial Team added an answer If you use Object, then clients must pass in something… May 11, 2026 at 6:46 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.