Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a redirect situation where the site is part dynamic and part generated .html files.

For example, and are actually static html files

Whereas other URLs are dynamically generated, like

Both and are pointing to the same place. However I want to redirect all of the traffic from to

I'm so close but I'm running into an issue where Apache is adding .html to the end of my URLs for anything where a static .html file exists - which I don't want.

I want to redirect this: 

To this:

But Apache is making it this, instead (because 42.html is an actual html file):

I don't want that - I want it to redirect to

Here's what I started with:

RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]

RewriteRule ^(.*)$$1 [R=301,L]

I tried making the parameters and the .html optional, but the .html is still getting added on the redirect:

RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]

RewriteRule ^(.*)?(\.html)?$$1 [R=301,L]

What am I doing wrong? Really appreciate it :)

share|improve this question
How are the static HTML files being served if the request doesn't include ".html"? Are there other rewrite rules which add the ".html" and are interfering with this? – mgorven Mar 26 '12 at 22:51

I blame MultiViews!

Try setting Options -MultiViews to disable the extension-guessing behavior.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.